Parser

Parser

The main class that arranges the whole parsing process.

Constructor

new Parser(UA, skipParsingopt)

Source:

Create instance of Parser

Parameters:
Name Type Attributes Default Description
UA String

User-Agent string

skipParsing Boolean <optional>
false

parser can skip parsing in purpose of performance improvements if you need to make a more particular parsing like Parser#parseBrowser or Parser#parsePlatform

Methods

getBrowser() → {Object}

Source:

Get parsed browser object

Returns:
Type
Object

getBrowserName() → {String}

Source:

Get browser's name

Returns:

Browser's name or an empty string

Type
String

getBrowserVersion() → {String}

Source:

Get browser's version

Returns:

version of browser

Type
String

getEngine() → {Object}

Source:

Get parsed engine

Returns:
Type
Object

getOS() → {Object}

Source:

Get OS

Example
this.getOS();
{
  name: 'macOS',
  version: '10.11.12'
}
Returns:
Type
Object

getOSName(toLowerCaseopt) → {String}

Source:

Get OS name

Parameters:
Name Type Attributes Description
toLowerCase Boolean <optional>

return lower-cased value

Returns:

name of the OS — macOS, Windows, Linux, etc.

Type
String

getOSVersion() → {String}

Source:

Get OS version

Returns:

full version with dots ('10.11.12', '5.6', etc)

Type
String

getPlatform() → {Object}

Source:

Get parsed platform

Returns:
Type
Object

getPlatformType(toLowerCaseopt) → {*}

Source:

Get platform name

Parameters:
Name Type Attributes Default Description
toLowerCase Boolean <optional>
false
Returns:
Type
*

getResult() → {ParsedResult}

Source:

Get parsed result

Returns:
Type
ParsedResult

getUA() → {String}

Source:

Get UserAgent string of current Parser instance

Returns:

User-Agent String of the current object

Type
String

is(anything) → {Boolean}

Source:

Is anything? Check if the browser is called "anything", the OS called "anything" or the platform called "anything"

Parameters:
Name Type Description
anything String
Returns:
Type
Boolean

parse()

Source:

Parse full information about the browser

parseBrowser() → {Object}

Source:

Get parsed browser object

Returns:
Type
Object

parseEngine() → {Object}

Source:

Get parsed platform

Returns:
Type
Object

parseOS() → {*|Object}

Source:

Parse OS and save it to this.parsedResult.os

Returns:
Type
* | Object

parsePlatform() → {Object}

Source:

Get parsed platform

Returns:
Type
Object

satisfies(checkTree) → {Boolean|undefined}

Source:

Check if parsed browser matches certain conditions

Example
const browser = new Bowser(UA);
if (browser.check({chrome: '>118.01.1322' }))
// or with os
if (browser.check({windows: { chrome: '>118.01.1322' } }))
// or with platforms
if (browser.check({desktop: { chrome: '>118.01.1322' } }))
Parameters:
Name Type Description
checkTree Object

It's one or two layered object, which can include a platform or an OS on the first layer and should have browsers specs on the bottom-laying layer

Returns:

Whether the browser satisfies the set conditions or not. Returns undefined when the browser is no described in the checkTree object.

Type
Boolean | undefined

some(anythings) → {Boolean}

Source:

Check if any of the given values satisfies this.is(anything)

Parameters:
Name Type Description
anythings Array.<String>
Returns:
Type
Boolean

test(regex) → {Boolean}

Source:

Test a UA string for a regexp

Parameters:
Name Type Description
regex RegExp
Returns:
Type
Boolean