diff --git a/src/parser.js b/src/parser.js index 631cbf8..5711a7a 100644 --- a/src/parser.js +++ b/src/parser.js @@ -198,14 +198,14 @@ class Parser { * @param {Boolean} toLowerCase * @return {*} */ - getPlatformName(toLowerCase) { - const { name } = this.getPlatform(); + getPlatformType(toLowerCase) { + const { type } = this.getPlatform(); if (toLowerCase) { - return String(name).toLowerCase() || ''; + return String(type).toLowerCase() || ''; } - return name || ''; + return type || ''; } /** @@ -342,8 +342,18 @@ class Parser { return this.getOSName(true) === String(osName).toLowerCase(); } - isPlatform(platformName) { - return this.getPlatformName(true) === String(platformName).toLowerCase(); + isPlatform(platformType) { + return this.getPlatformType(true) === String(platformType).toLowerCase(); + } + + /** + * Is anything? Check if the browser is called "anything", + * the OS called "anything" or the platform called "anything" + * @param {String} anything + * @returns {Boolean} + */ + is(anything) { + return this.isBrowser(anything) || this.isOs(anything) || this.isPlatform(anything); } } diff --git a/test/unit/parser.js b/test/unit/parser.js index 8c9c0e2..09004cd 100644 --- a/test/unit/parser.js +++ b/test/unit/parser.js @@ -72,3 +72,9 @@ test('Parser.check should make complex comparison', (t) => { opera: '>42', }), true); }); + +test('Parser.is should pass', (t) => { + t.is(parser.is('opera'), true); + t.is(parser.is('desktop'), true); + t.is(parser.is('macos'), true); +});