diff --git a/src/parser.js b/src/parser.js index 2ce0fc9..df98540 100644 --- a/src/parser.js +++ b/src/parser.js @@ -427,6 +427,15 @@ class Parser { is(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; diff --git a/test/unit/parser.js b/test/unit/parser.js index a600752..afb643e 100644 --- a/test/unit/parser.js +++ b/test/unit/parser.js @@ -114,3 +114,11 @@ test('Parser.is should pass', (t) => { t.is(parser.is('desktop'), 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); +});