mirror of
https://github.com/lancedikson/bowser
synced 2024-10-27 20:34:22 +00:00
Add parser.some function
This commit is contained in:
parent
2ae6ce1820
commit
53e7af3a38
@ -427,6 +427,15 @@ class Parser {
|
|||||||
is(anything) {
|
is(anything) {
|
||||||
return this.isBrowser(anything) || this.isOS(anything) || this.isPlatform(anything);
|
return this.isBrowser(anything) || this.isOS(anything) || this.isPlatform(anything);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if any of the given values satifies this.is(anything)
|
||||||
|
* @param {String[]} anythings
|
||||||
|
* @returns {Boolean}
|
||||||
|
*/
|
||||||
|
some(anythings = []) {
|
||||||
|
return anythings.some(anything => this.is(anything));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Parser;
|
export default Parser;
|
||||||
|
@ -114,3 +114,11 @@ test('Parser.is should pass', (t) => {
|
|||||||
t.is(parser.is('desktop'), true);
|
t.is(parser.is('desktop'), true);
|
||||||
t.is(parser.is('macos'), true);
|
t.is(parser.is('macos'), true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Parser.some should pass', (t) => {
|
||||||
|
t.is(parser.some(['opera', 'chrome', 'firefox']), true);
|
||||||
|
t.is(parser.some(['macos', 'windows']), true);
|
||||||
|
t.is(parser.some(['chrome', 'firefox']), false);
|
||||||
|
t.is(parser.some([]), false);
|
||||||
|
t.is(parser.some(), false);
|
||||||
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user