mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 14:57:10 +00:00
Merge pull request #32328 from nju33/add/browserslist-useragent
Add browserslist-useragent
This commit is contained in:
@@ -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
@@ -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"]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user