UNPKG

2.67 kBTypeScriptView Raw
1export = Negotiator;
2
3declare class Negotiator {
4 /**
5 * The negotiator constructor receives a request object
6 */
7 constructor(req: { headers: Negotiator.Headers });
8
9 /**
10 * Returns the most preferred media type from the client.
11 *
12 * @param [availableMediaTypes] When provided, returns the most preferred media type
13 * from a list of available media types.
14 */
15 mediaType(availableMediaTypes?: string[]): string | undefined;
16
17 /**
18 * Returns an array of preferred media types ordered by the client preference
19 *
20 * @param [availableMediaTypes] When provided, returns an array of preferred media
21 * types ordered by priority from a list of available media types.
22 */
23 mediaTypes(availableMediaTypes?: string[]): string[];
24
25 /**
26 * Returns the most preferred language from the client.
27 *
28 * @param [availableLanguages] When provided, returns the most preferred language
29 * from a list of available languages.
30 */
31 language(availableLanguages?: string[]): string | undefined;
32
33 /**
34 * Returns an array of preferred languages ordered by the client preference.
35 *
36 * @param [availableLanguages] When provided, returns an array of preferred languages
37 * ordered by priority from a list of available languages.
38 */
39 languages(availableLanguages?: string[]): string[];
40
41 /**
42 * Returns the most preferred charset from the client.
43 *
44 * @param [availableCharsets] When provided, returns the most preferred charset
45 * from a list of available charsets.
46 */
47 charset(availableCharsets?: string[]): string | undefined;
48
49 /**
50 * Returns an array of preferred charsets ordered by the client preference.
51 *
52 * @param [availableCharsets] When provided, returns an array of preferred charsets
53 * ordered by priority from a list of available charsets.
54 */
55 charsets(availableCharsets?: string[]): string[];
56
57 /**
58 * Returns the most preferred encoding from the client.
59 *
60 * @param [availableEncodings] When provided, returns the most preferred encoding
61 * from a list of available encodings.
62 */
63 encoding(availableEncodings?: string[]): string | undefined;
64
65 /**
66 * Returns an array of preferred encodings ordered by the client preference.
67 *
68 * @param [availableEncodings] When provided, returns an array of preferred encodings
69 * ordered by priority from a list of available encodings.
70 */
71 encodings(availableEncodings?: string[]): string[];
72}
73
74declare namespace Negotiator {
75 interface Headers {
76 [key: string]: string | string[] | undefined;
77 }
78}