mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 07:47:04 +00:00
Merge pull request #12937 from Bomret/accepts
Added type declarations for accept.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import accepts = require("accepts");
|
||||
|
||||
const req: any = {};
|
||||
|
||||
const accept = accepts(req);
|
||||
|
||||
const charsets = accept.charsets();
|
||||
const charsetFromEmpty = accept.charset();
|
||||
const charsetFromParams = accept.charset("json", "text");
|
||||
const charsetFromArray = accept.charset(["json", "text"]);
|
||||
|
||||
const encodings = accept.encodings();
|
||||
const encodingFromEmpty = accept.encoding();
|
||||
const encodingFromParams = accept.encoding("json", "text");
|
||||
const encodingFromArray = accept.encoding(["json", "text"]);
|
||||
|
||||
const languages = accept.languages();
|
||||
const languageFromEmpty = accept.language();
|
||||
const languageFromParams = accept.language("json", "text");
|
||||
const languageFromArray = accept.language(["json", "text"]);
|
||||
|
||||
const types = accept.types();
|
||||
const typeFromEmpty = accept.type();
|
||||
const typeFromParams = accept.type("json", "text");
|
||||
const typeFromArray = accept.type(["json", "text"]);
|
||||
Vendored
+31
@@ -0,0 +1,31 @@
|
||||
// Type definitions for accepts
|
||||
// Project: https://github.com/jshttp/accepts
|
||||
// Definitions by: Stefan Reichel <https://github.com/bomret>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
import { IncomingMessage } from "http";
|
||||
|
||||
declare namespace accepts {
|
||||
export interface Accepts {
|
||||
charset(charsets: string[]): string | string[] | boolean;
|
||||
charset(...charsets: string[]): string | string[] | boolean;
|
||||
charsets(): string[];
|
||||
|
||||
encoding(encodings: string[]): string | string[] | boolean;
|
||||
encoding(...encodings: string[]): string | string[] | boolean;
|
||||
encodings(): string[];
|
||||
|
||||
language(languages: string[]): string | string[] | boolean;
|
||||
language(...languages: string[]): string | string[] | boolean;
|
||||
languages(): string[];
|
||||
|
||||
type(types: string[]): string | string[] | boolean;
|
||||
type(...types: string[]): string | string[] | boolean;
|
||||
types(): string[];
|
||||
}
|
||||
}
|
||||
|
||||
declare function accepts(req: IncomingMessage): accepts.Accepts;
|
||||
|
||||
export = accepts;
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"accepts-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
Reference in New Issue
Block a user