1
0
mirror of https://github.com/lancedikson/bowser synced 2025-06-13 13:03:52 +00:00

feat: update types of parser methods

This commit is contained in:
Amelie Cheng 2020-10-05 13:35:46 +08:00
parent f09411489c
commit 1a2cf47609
2 changed files with 45 additions and 6 deletions

34
index.d.ts vendored
View File

@ -130,10 +130,11 @@ declare namespace Bowser {
* Is anything? Check if the browser is called "anything", * Is anything? Check if the browser is called "anything",
* the OS called "anything" or the platform called "anything" * the OS called "anything" or the platform called "anything"
* @param {String} anything * @param {String} anything
* @param [includingAlias=false] The flag showing whether alias will be included into comparison
* @returns {Boolean} * @returns {Boolean}
*/ */
is(anything: any): boolean; is(anything: any, includingAlias?: boolean): boolean;
/** /**
* Parse full information about the browser * Parse full information about the browser
@ -191,18 +192,41 @@ declare namespace Bowser {
satisfies(checkTree: checkTree): boolean | undefined; satisfies(checkTree: checkTree): boolean | undefined;
/** /**
* Check if the browser name equals the passed string * Check if the browser name equals the passed string
* @param browserName The string to compare with the browser name * @param {string} browserName The string to compare with the browser name
* @param [includingAlias=false] The flag showing whether alias will be included into comparison * @param [includingAlias=false] The flag showing whether alias will be included into comparison
* @returns {boolean} * @returns {boolean}
*/ */
isBrowser(browserName: string, includingAlias?: boolean): boolean; isBrowser(browserName: string, includingAlias?: boolean): boolean;
/** /**
* Check if any of the given values satifies `.is(anything)` * Check if the engine name equals the passed string
* @param {string} engineName The string to compare with the engine name
* @returns {boolean}
*/
isEngine(engineName: string): boolean;
/**
* Check if the platform type equals the passed string
* @param {string} platformType The string to compare with the platform type
* @returns {boolean}
*/
isPlatform(platformType: string): boolean;
/**
* Check if the OS name equals the passed string
* @param {string} osName The string to compare with the OS name
* @returns {boolean}
*/
isOS(osName: string): boolean;
/**
* Check if any of the given values satisfies `.is(anything)`
* @param {string[]} anythings * @param {string[]} anythings
* @returns {boolean} true if at least one condition is satisfied, false otherwise. * @returns {boolean} true if at least one condition is satisfied, false otherwise.
*/ */

View File

@ -408,7 +408,7 @@ class Parser {
/** /**
* Check if the browser name equals the passed string * Check if the browser name equals the passed string
* @param browserName The string to compare with the browser name * @param {string} browserName The string to compare with the browser name
* @param [includingAlias=false] The flag showing whether alias will be included into comparison * @param [includingAlias=false] The flag showing whether alias will be included into comparison
* @returns {boolean} * @returns {boolean}
*/ */
@ -459,14 +459,29 @@ class Parser {
) > -1; ) > -1;
} }
/**
* Check if the OS name equals the passed string
* @param {string} osName The string to compare with the OS name
* @returns {boolean}
*/
isOS(osName) { isOS(osName) {
return this.getOSName(true) === String(osName).toLowerCase(); return this.getOSName(true) === String(osName).toLowerCase();
} }
/**
* Check if the platform type equals the passed string
* @param {string} platformType The string to compare with the platform type
* @returns {boolean}
*/
isPlatform(platformType) { isPlatform(platformType) {
return this.getPlatformType(true) === String(platformType).toLowerCase(); return this.getPlatformType(true) === String(platformType).toLowerCase();
} }
/**
* Check if the engine name equals the passed string
* @param {string} engineName The string to compare with the engine name
* @returns {boolean}
*/
isEngine(engineName) { isEngine(engineName) {
return this.getEngineName(true) === String(engineName).toLowerCase(); return this.getEngineName(true) === String(engineName).toLowerCase();
} }