[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:
Niklas Wulf 2017-09-21 12:15:46 +02:00
parent c1534fd023
commit d73ea3885a
No known key found for this signature in database
GPG Key ID: 8D6BA0AC5F3E2681
4 changed files with 57 additions and 0 deletions

View 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
View 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;
}

View 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"]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }