1
0
mirror of https://github.com/lancedikson/bowser synced 2026-03-02 03:40:27 +00:00

Fix Bowser constructor, add some tests

This commit is contained in:
Denis Demchenko
2018-06-30 17:25:47 +03:00
parent 98007768b4
commit e7e6abff8b
2 changed files with 23 additions and 4 deletions

View File

@@ -17,21 +17,22 @@ import Parser from './parser';
class Bowser {
/**
* Creates an object that parses UA
* @param UA
* @param {String} UA — UserAgent string
* @param {Boolean} [skipParsing=false] — same as skipParsing for Parser
*
* @example
* const bowser = new Bowser(window.navigator.userAgent);
* bowser.getBrowser()
*/
constructor(UA) {
constructor(UA, skipParsing=false) {
if (!UA) {
throw new Error('UserAgent is not defined');
}
return new Parser(UA);
return new Parser(UA, skipParsing);
}
static parse(UA) {
return (new this.constructor(UA)).getResult();
return (new Bowser(UA)).getResult();
}
/**