@cainiaofe/cn-utils
Version:
菜鸟前端基础工具库
70 lines (69 loc) • 1.47 kB
TypeScript
/**
* The main class that arranges the whole parsing process.
*/
declare class Parser {
/**
* Create instance of Parser
*
* @param {String} UA User-Agent string
* @throw {Error} in case of empty UA String
*
* @constructor
*/
_ua: '';
parsedResult: {
os: {
name: '';
version: '';
};
};
constructor(UA: any);
/**
* Get UserAgent string of current Parser instance
* @return {String} User-Agent String of the current <Parser> object
*
* @public
*/
getUA(): "";
/**
* Test a UA string for a regexp
* @param {RegExp} regex
* @return {Boolean}
*/
test(regex: any): any;
/**
* Get OS
* @return {Object}
*
* @example
* this.getOS();
* {
* name: 'macOS',
* version: '10.11.12'
* }
*/
getOS(): {
name: "";
version: "";
};
/**
* Parse OS and save it to this.parsedResult.os
* @return {*|{}}
*/
parseOS(): {
name: "";
version: "";
};
/**
* Get OS name
* @param {Boolean} [toLowerCase] return lower-cased value
* @return {String} name of the OS — macOS, Windows, Linux, etc.
*/
getOSName(toLowerCase: any): string;
/**
* Get OS version
* @return {String} full version with dots ('10.11.12', '5.6', etc)
*/
getOSVersion(): "";
}
export default Parser;