mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
[accept-language-parser] Add accept-language-parser
This commit adds initial support for the accept-language-parser module which is currently at version 1.4.1 I am not in any way related to the module.
This commit is contained in:
parent
c1534fd023
commit
d73ea3885a
25
types/accept-language-parser/accept-language-parser-tests.ts
Normal file
25
types/accept-language-parser/accept-language-parser-tests.ts
Normal file
@ -0,0 +1,25 @@
|
||||
// https://github.com/opentable/accept-language-parser/blob/v1.4.1/index.js
|
||||
|
||||
import * as AcceptLanguageParser from '.';
|
||||
|
||||
const l1: AcceptLanguageParser.Language = {
|
||||
code: 'en',
|
||||
script: 'Latn',
|
||||
region: 'GB',
|
||||
quality: 0.9
|
||||
};
|
||||
|
||||
const l2: AcceptLanguageParser.Language = {
|
||||
code: 'en',
|
||||
quality: 0.9
|
||||
};
|
||||
|
||||
const l3: AcceptLanguageParser.Language = {
|
||||
code: 'en',
|
||||
script: null,
|
||||
quality: 0.9
|
||||
};
|
||||
|
||||
AcceptLanguageParser.parse('');
|
||||
AcceptLanguageParser.pick([''], '');
|
||||
AcceptLanguageParser.pick([''], [l1, l2, l3]);
|
||||
16
types/accept-language-parser/index.d.ts
vendored
Normal file
16
types/accept-language-parser/index.d.ts
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
// Type definitions for accept-language-parser 1.4
|
||||
// Project: https://github.com/opentable/accept-language-parser
|
||||
// Definitions by: Niklas Wulf <https://github.com/kampfgnom>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// https://github.com/opentable/accept-language-parser/blob/v1.4.1/index.js
|
||||
|
||||
export function parse(acceptLanguage: string): Language[];
|
||||
export function pick(supportedLanguages: string[], acceptLanguage: string | Language[]): Language | null;
|
||||
|
||||
export interface Language {
|
||||
code: string;
|
||||
script?: string | null;
|
||||
region?: string;
|
||||
quality: number;
|
||||
}
|
||||
15
types/accept-language-parser/tsconfig.json
Normal file
15
types/accept-language-parser/tsconfig.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": ["index.d.ts", "accept-language-parser-tests.ts"]
|
||||
}
|
||||
1
types/accept-language-parser/tslint.json
Normal file
1
types/accept-language-parser/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user