Merge pull request #32328 from nju33/add/browserslist-useragent

Add browserslist-useragent
This commit is contained in:
Benjamin Lichtman
2019-01-22 12:43:49 -08:00
committed by GitHub
4 changed files with 72 additions and 0 deletions
@@ -0,0 +1,30 @@
import {
matchesUA,
resolveUserAgent,
normalizeQuery
} from 'browserslist-useragent';
// $ExpectType boolean
matchesUA(
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36'
);
// $ExpectType boolean
matchesUA(
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36',
{
browsers: ['defaults'],
env: 'production',
ignorePath: true,
ignoreMinor: false,
allowHigherVersions: false
}
);
// $ExpectType ResolvedUserAgent
resolveUserAgent(
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36'
);
// $ExpectType string
normalizeQuery('defaults');
+24
View File
@@ -0,0 +1,24 @@
// Type definitions for browserslist-useragent 3.0
// Project: https://github.com/browserslist/browserslist-useragent (Does not have to be to GitHub, but prefer linking to a source code repository rather than to a project website.)
// Definitions by: nju33 <https://github.com/nju33>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export interface ResolvedUserAgent {
family: string;
version: string;
}
export interface BrowserslistUseragentOptions {
browsers?: string[];
env?: string;
ignorePath?: boolean;
ignoreMinor?: boolean;
allowHigherVersions?: boolean;
}
export function matchesUA(
uaString: string,
opts?: BrowserslistUseragentOptions
): boolean;
export function resolveUserAgent(uaString: string): ResolvedUserAgent;
export function normalizeQuery(query: string): string;
@@ -0,0 +1,17 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"esModuleInterop": true
},
"files": ["index.d.ts", "browserslist-useragent-tests.ts"]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }