mirror of
https://github.com/lancedikson/bowser
synced 2024-10-27 20:34:22 +00:00
Merge pull request #281 from alexandercerutti/master
Fixed typings indentation and edited readme
This commit is contained in:
commit
700732f7b3
@ -13,10 +13,12 @@ A browser detector. Because sometimes, there is no other way, and not even good
|
|||||||
|
|
||||||
The library is made to help to detect what browser your user has and gives you a convenient API to filter the users somehow depending on their browsers.
|
The library is made to help to detect what browser your user has and gives you a convenient API to filter the users somehow depending on their browsers.
|
||||||
|
|
||||||
_Please, note that this is an alpha version. Check out the [1.x](https://github.com/lancedikson/bowser/tree/v1.x) branch for a stable version._
|
|
||||||
|
|
||||||
**Changes of version 2.0**
|
**Changes of version 2.0**
|
||||||
The upcoming 2.0 version has drastically changed API. All available methods can be found in the `docs` folder from now on and on a webpage soon.
|
|
||||||
|
The version 2.0 has drastically changed API. All available methods can be found in the `docs` folder from now on and on a webpage soon.
|
||||||
|
|
||||||
|
_For legacy code, check out the [1.x](https://github.com/lancedikson/bowser/tree/v1.x) branch and install it through `npm install bowser@1.9.4`._
|
||||||
|
|
||||||
|
|
||||||
# Use cases
|
# Use cases
|
||||||
|
|
||||||
|
54
index.d.ts
vendored
54
index.d.ts
vendored
@ -13,7 +13,7 @@ declare namespace Bowser {
|
|||||||
* @param {boolean} skipParsing
|
* @param {boolean} skipParsing
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function getParser(UA: string, skipParsing?: boolean): Parser.Parser;
|
function getParser(UA: string, skipParsing?: boolean): Parser.Parser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a Parser instance and runs Parser.getResult immediately
|
* Creates a Parser instance and runs Parser.getResult immediately
|
||||||
@ -26,28 +26,28 @@ declare namespace Bowser {
|
|||||||
|
|
||||||
declare namespace Parser {
|
declare namespace Parser {
|
||||||
class Parser {
|
class Parser {
|
||||||
constructor(UA: string, skipParsing?: boolean);
|
constructor(UA: string, skipParsing?: boolean);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get parsed browser object
|
* Get parsed browser object
|
||||||
* @return {BrowserDetails} Browser's details
|
* @return {BrowserDetails} Browser's details
|
||||||
*/
|
*/
|
||||||
|
|
||||||
getBrowser(): BrowserDetails;
|
getBrowser(): BrowserDetails;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get browser's name
|
* Get browser's name
|
||||||
* @return {String} Browser's name or an empty string
|
* @return {String} Browser's name or an empty string
|
||||||
*/
|
*/
|
||||||
|
|
||||||
getBrowserName(): string;
|
getBrowserName(): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get browser's version
|
* Get browser's version
|
||||||
* @return {String} version of browser
|
* @return {String} version of browser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
getBrowserVersion(): string;
|
getBrowserVersion(): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get OS
|
* Get OS
|
||||||
@ -60,7 +60,7 @@ declare namespace Parser {
|
|||||||
* // }
|
* // }
|
||||||
*/
|
*/
|
||||||
|
|
||||||
getOS(): OSDetails;
|
getOS(): OSDetails;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get OS name
|
* Get OS name
|
||||||
@ -68,49 +68,49 @@ declare namespace Parser {
|
|||||||
* @return {String} name of the OS — macOS, Windows, Linux, etc.
|
* @return {String} name of the OS — macOS, Windows, Linux, etc.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
getOSName(toLowerCase?: boolean): string;
|
getOSName(toLowerCase?: boolean): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get OS version
|
* Get OS version
|
||||||
* @return {String} full version with dots ('10.11.12', '5.6', etc)
|
* @return {String} full version with dots ('10.11.12', '5.6', etc)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
getOSVersion(): string;
|
getOSVersion(): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get parsed platform
|
* Get parsed platform
|
||||||
* @returns {PlatformDetails}
|
* @returns {PlatformDetails}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
getPlatform(): PlatformDetails;
|
getPlatform(): PlatformDetails;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get platform name
|
* Get platform name
|
||||||
* @param {boolean} toLowerCase
|
* @param {boolean} toLowerCase
|
||||||
*/
|
*/
|
||||||
|
|
||||||
getPlatformType(toLowerCase?: boolean): string;
|
getPlatformType(toLowerCase?: boolean): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get parsed engine
|
* Get parsed engine
|
||||||
* @returns {EngineDetails}
|
* @returns {EngineDetails}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
getEngine(): EngineDetails;
|
getEngine(): EngineDetails;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get parsed result
|
* Get parsed result
|
||||||
* @return {ParsedResult}
|
* @return {ParsedResult}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
getResult(): ParsedResult;
|
getResult(): ParsedResult;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get UserAgent string of current Parser instance
|
* Get UserAgent string of current Parser instance
|
||||||
* @return {String} User-Agent String of the current <Parser> object
|
* @return {String} User-Agent String of the current <Parser> object
|
||||||
*/
|
*/
|
||||||
|
|
||||||
getUA(): string;
|
getUA(): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is anything? Check if the browser is called "anything",
|
* Is anything? Check if the browser is called "anything",
|
||||||
@ -119,41 +119,41 @@ declare namespace Parser {
|
|||||||
* @returns {Boolean}
|
* @returns {Boolean}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
is(anything: any): boolean;
|
is(anything: any): boolean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse full information about the browser
|
* Parse full information about the browser
|
||||||
*/
|
*/
|
||||||
|
|
||||||
parse(): void;
|
parse(): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get parsed browser object
|
* Get parsed browser object
|
||||||
* @returns {BrowserDetails}
|
* @returns {BrowserDetails}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
parseBrowser(): BrowserDetails;
|
parseBrowser(): BrowserDetails;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get parsed engine
|
* Get parsed engine
|
||||||
* @returns {EngineDetails}
|
* @returns {EngineDetails}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
parseEngine(): EngineDetails;
|
parseEngine(): EngineDetails;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse OS and save it to this.parsedResult.os
|
* Parse OS and save it to this.parsedResult.os
|
||||||
* @returns {OSDetails}
|
* @returns {OSDetails}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
parseOS(): OSDetails;
|
parseOS(): OSDetails;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get parsed platform
|
* Get parsed platform
|
||||||
* @returns {PlatformDetails}
|
* @returns {PlatformDetails}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
parsePlatform(): PlatformDetails;
|
parsePlatform(): PlatformDetails;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if parsed browser matches certain conditions
|
* Check if parsed browser matches certain conditions
|
||||||
@ -174,7 +174,7 @@ declare namespace Parser {
|
|||||||
* if (browser.check({desktop: { chrome: '>118.01.1322' } }))
|
* if (browser.check({desktop: { chrome: '>118.01.1322' } }))
|
||||||
*/
|
*/
|
||||||
|
|
||||||
satisfies(checkTree: checkTree): boolean | undefined;
|
satisfies(checkTree: checkTree): boolean | undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if any of the given values satifies `.is(anything)`
|
* Check if any of the given values satifies `.is(anything)`
|
||||||
@ -182,7 +182,7 @@ declare namespace Parser {
|
|||||||
* @returns {boolean} true if at least one condition is satisfied, false otherwise.
|
* @returns {boolean} true if at least one condition is satisfied, false otherwise.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
some(anythings: string[]): boolean | undefined;
|
some(anythings: string[]): boolean | undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test a UA string for a regexp
|
* Test a UA string for a regexp
|
||||||
@ -191,34 +191,34 @@ declare namespace Parser {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
test(regex: RegExp): boolean;
|
test(regex: RegExp): boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ParsedResult {
|
interface ParsedResult {
|
||||||
browser: BrowserDetails;
|
browser: BrowserDetails;
|
||||||
os: OSDetails;
|
os: OSDetails;
|
||||||
platform: PlatformDetails;
|
platform: PlatformDetails;
|
||||||
engine: EngineDetails;
|
engine: EngineDetails;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Details {
|
interface Details {
|
||||||
name?: string;
|
name?: string;
|
||||||
version?: string;
|
version?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface OSDetails extends Details {
|
interface OSDetails extends Details {
|
||||||
versionName?: string;
|
versionName?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface PlatformDetails {
|
interface PlatformDetails {
|
||||||
type?: string;
|
type?: string;
|
||||||
vendor?: string;
|
vendor?: string;
|
||||||
model?: string;
|
model?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
type BrowserDetails = Details;
|
type BrowserDetails = Details;
|
||||||
type EngineDetails = Details;
|
type EngineDetails = Details;
|
||||||
|
|
||||||
interface checkTree {
|
interface checkTree {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user