Skip to content

Commit

Permalink
Merge 53e7af3 into 2ae6ce1
Browse files Browse the repository at this point in the history
  • Loading branch information
mjlescano committed Jul 17, 2018
2 parents 2ae6ce1 + 53e7af3 commit a3d5738
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
8 changes: 8 additions & 0 deletions test/unit/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

0 comments on commit a3d5738

Please sign in to comment.