UNPKG

3.09 kBTypeScriptView Raw
1// Type definitions for qs 6.9
2// Project: https://github.com/ljharb/qs
3// Definitions by: Roman Korneev <https://github.com/RWander>
4// Leon Yu <https://github.com/leonyu>
5// Belinda Teh <https://github.com/tehbelinda>
6// Melvin Lee <https://github.com/zyml>
7// Arturs Vonda <https://github.com/artursvonda>
8// Carlos Bonetti <https://github.com/CarlosBonetti>
9// Dan Smith <https://github.com/dpsmith3>
10// Hunter Perrin <https://github.com/hperrin>
11// Jordan Harband <https://github.com/ljharb>
12// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
13export = QueryString;
14export as namespace qs;
15
16declare namespace QueryString {
17 type defaultEncoder = (str: any, defaultEncoder?: any, charset?: string) => string;
18 type defaultDecoder = (str: string, decoder?: any, charset?: string) => string;
19
20 interface IStringifyOptions {
21 delimiter?: string | undefined;
22 strictNullHandling?: boolean | undefined;
23 skipNulls?: boolean | undefined;
24 encode?: boolean | undefined;
25 encoder?: ((str: any, defaultEncoder: defaultEncoder, charset: string, type: 'key' | 'value') => string) | undefined;
26 filter?: Array<string | number> | ((prefix: string, value: any) => any) | undefined;
27 arrayFormat?: 'indices' | 'brackets' | 'repeat' | 'comma' | undefined;
28 indices?: boolean | undefined;
29 sort?: ((a: any, b: any) => number) | undefined;
30 serializeDate?: ((d: Date) => string) | undefined;
31 format?: 'RFC1738' | 'RFC3986' | undefined;
32 encodeValuesOnly?: boolean | undefined;
33 addQueryPrefix?: boolean | undefined;
34 allowDots?: boolean | undefined;
35 charset?: 'utf-8' | 'iso-8859-1' | undefined;
36 charsetSentinel?: boolean | undefined;
37 }
38
39 interface IParseOptions {
40 comma?: boolean | undefined;
41 delimiter?: string | RegExp | undefined;
42 depth?: number | false | undefined;
43 decoder?: ((str: string, defaultDecoder: defaultDecoder, charset: string, type: 'key' | 'value') => any) | undefined;
44 arrayLimit?: number | undefined;
45 parseArrays?: boolean | undefined;
46 allowDots?: boolean | undefined;
47 plainObjects?: boolean | undefined;
48 allowPrototypes?: boolean | undefined;
49 parameterLimit?: number | undefined;
50 strictNullHandling?: boolean | undefined;
51 ignoreQueryPrefix?: boolean | undefined;
52 charset?: 'utf-8' | 'iso-8859-1' | undefined;
53 charsetSentinel?: boolean | undefined;
54 interpretNumericEntities?: boolean | undefined;
55 }
56
57 interface ParsedQs { [key: string]: undefined | string | string[] | ParsedQs | ParsedQs[] }
58
59 function stringify(obj: any, options?: IStringifyOptions): string;
60 function parse(str: string, options?: IParseOptions & { decoder?: never | undefined }): ParsedQs;
61 function parse(str: string | Record<string, string>, options?: IParseOptions): { [key: string]: unknown };
62}
63
\No newline at end of file