1 | export = QueryString;
|
2 | export as namespace qs;
|
3 |
|
4 | declare namespace QueryString {
|
5 | type defaultEncoder = (str: any, defaultEncoder?: any, charset?: string) => string;
|
6 | type defaultDecoder = (str: string, decoder?: any, charset?: string) => string;
|
7 |
|
8 | type BooleanOptional = boolean | undefined;
|
9 |
|
10 | interface IStringifyBaseOptions {
|
11 | delimiter?: string | undefined;
|
12 | strictNullHandling?: boolean | undefined;
|
13 | skipNulls?: boolean | undefined;
|
14 | encode?: boolean | undefined;
|
15 | encoder?:
|
16 | | ((str: any, defaultEncoder: defaultEncoder, charset: string, type: "key" | "value") => string)
|
17 | | undefined;
|
18 | filter?: Array<string | number> | ((prefix: string, value: any) => any) | undefined;
|
19 | arrayFormat?: "indices" | "brackets" | "repeat" | "comma" | undefined;
|
20 | indices?: boolean | undefined;
|
21 | sort?: ((a: string, b: string) => number) | undefined;
|
22 | serializeDate?: ((d: Date) => string) | undefined;
|
23 | format?: "RFC1738" | "RFC3986" | undefined;
|
24 | encodeValuesOnly?: boolean | undefined;
|
25 | addQueryPrefix?: boolean | undefined;
|
26 | charset?: "utf-8" | "iso-8859-1" | undefined;
|
27 | charsetSentinel?: boolean | undefined;
|
28 | allowEmptyArrays?: boolean | undefined;
|
29 | commaRoundTrip?: boolean | undefined;
|
30 | }
|
31 |
|
32 | type IStringifyDynamicOptions<AllowDots extends BooleanOptional> = AllowDots extends true
|
33 | ? { allowDots?: AllowDots; encodeDotInKeys?: boolean }
|
34 | : { allowDots?: boolean; encodeDotInKeys?: false };
|
35 |
|
36 | type IStringifyOptions<AllowDots extends BooleanOptional = undefined> =
|
37 | & IStringifyBaseOptions
|
38 | & IStringifyDynamicOptions<AllowDots>;
|
39 |
|
40 | interface IParseBaseOptions {
|
41 | comma?: boolean | undefined;
|
42 | delimiter?: string | RegExp | undefined;
|
43 | depth?: number | false | undefined;
|
44 | decoder?:
|
45 | | ((str: string, defaultDecoder: defaultDecoder, charset: string, type: "key" | "value") => any)
|
46 | | undefined;
|
47 | arrayLimit?: number | undefined;
|
48 | parseArrays?: boolean | undefined;
|
49 | plainObjects?: boolean | undefined;
|
50 | allowPrototypes?: boolean | undefined;
|
51 | allowSparse?: boolean | undefined;
|
52 | parameterLimit?: number | undefined;
|
53 | strictNullHandling?: boolean | undefined;
|
54 | ignoreQueryPrefix?: boolean | undefined;
|
55 | charset?: "utf-8" | "iso-8859-1" | undefined;
|
56 | charsetSentinel?: boolean | undefined;
|
57 | interpretNumericEntities?: boolean | undefined;
|
58 | allowEmptyArrays?: boolean | undefined;
|
59 | duplicates?: "combine" | "first" | "last" | undefined;
|
60 | strictDepth?: boolean | undefined;
|
61 | }
|
62 |
|
63 | type IParseDynamicOptions<AllowDots extends BooleanOptional> = AllowDots extends true
|
64 | ? { allowDots?: AllowDots; decodeDotInKeys?: boolean }
|
65 | : { allowDots?: boolean; decodeDotInKeys?: false };
|
66 |
|
67 | type IParseOptions<AllowDots extends BooleanOptional = undefined> =
|
68 | & IParseBaseOptions
|
69 | & IParseDynamicOptions<AllowDots>;
|
70 |
|
71 | interface ParsedQs {
|
72 | [key: string]: undefined | string | string[] | ParsedQs | ParsedQs[];
|
73 | }
|
74 |
|
75 | function stringify(obj: any, options?: IStringifyOptions<BooleanOptional>): string;
|
76 | function parse(str: string, options?: IParseOptions<BooleanOptional> & { decoder?: never | undefined }): ParsedQs;
|
77 | function parse(
|
78 | str: string | Record<string, string>,
|
79 | options?: IParseOptions<BooleanOptional>,
|
80 | ): { [key: string]: unknown };
|
81 | }
|
82 |
|
\ | No newline at end of file |