Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update types of parser methods #449

Merged
merged 2 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,11 @@ declare namespace Bowser {
* Is anything? Check if the browser is called "anything",
* the OS called "anything" or the platform called "anything"
* @param {String} anything
* @param [includingAlias=false] The flag showing whether alias will be included into comparison
* @returns {Boolean}
*/

is(anything: any): boolean;
is(anything: any, includingAlias?: boolean): boolean;

/**
* Check if the browser name equals the passed string
Expand Down Expand Up @@ -233,7 +234,40 @@ declare namespace Bowser {
satisfies(checkTree: checkTree): boolean | undefined;

/**
* Check if any of the given values satifies `.is(anything)`
* Check if the browser name equals the passed string
* @param {string} browserName The string to compare with the browser name
* @param [includingAlias=false] The flag showing whether alias will be included into comparison
* @returns {boolean}
*/

isBrowser(browserName: string, includingAlias?: boolean): boolean;

/**
* 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
* @returns {boolean} true if at least one condition is satisfied, false otherwise.
*/
Expand Down
17 changes: 16 additions & 1 deletion src/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ class Parser {

/**
* 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
* @returns {boolean}
*/
Expand Down Expand Up @@ -459,14 +459,29 @@ class Parser {
) > -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) {
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) {
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) {
return this.getEngineName(true) === String(engineName).toLowerCase();
}
Expand Down