mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-12 19:59:02 +08:00
13
types/qs/index.d.ts
vendored
13
types/qs/index.d.ts
vendored
@@ -1,7 +1,9 @@
|
||||
// Type definitions for qs 6.2.0
|
||||
// Project: https://github.com/hapijs/qs
|
||||
// Definitions by: Roman Korneev <https://github.com/RWander>, Leon Yu <https://github.com/leonyu>,
|
||||
// Belinda Teh <https://github.com/tehbelinda>
|
||||
// Type definitions for qs 6.4.0
|
||||
// Project: https://github.com/ljharb/qs
|
||||
// Definitions by: Roman Korneev <https://github.com/RWander>
|
||||
// Leon Yu <https://github.com/leonyu>
|
||||
// Belinda Teh <https://github.com/tehbelinda>
|
||||
// Melvin Lee <https://github.com/zyml>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export = QueryString;
|
||||
@@ -18,6 +20,9 @@ declare namespace QueryString {
|
||||
arrayFormat?: 'indices' | 'brackets' | 'repeat';
|
||||
indices?: boolean;
|
||||
sort?: (a: any, b: any) => number;
|
||||
serializeDate?: (d: Date) => string;
|
||||
format?: 'RFC1738' | 'RFC3986';
|
||||
encodeValuesOnly?: boolean;
|
||||
}
|
||||
|
||||
interface IParseOptions {
|
||||
|
||||
@@ -254,3 +254,27 @@ qs.parse('a=b&c=d', { delimiter: '&' });
|
||||
var sorted = qs.stringify({ a: 1, c: 3, b: 2 }, { sort: (a, b) => a.localeCompare(b) })
|
||||
assert.equal(sorted, 'a=1&b=2&c=3')
|
||||
}
|
||||
|
||||
() => {
|
||||
var date = new Date(7);
|
||||
assert.equal(
|
||||
qs.stringify({ a: date }, { serializeDate: function (d) { return d.getTime().toString(); } }),
|
||||
'a=7'
|
||||
);
|
||||
}
|
||||
|
||||
() => {
|
||||
assert.equal(qs.stringify({ a: 'b c' }, { format : 'RFC3986' }), 'a=b%20c');
|
||||
}
|
||||
|
||||
() => {
|
||||
assert.equal(qs.stringify({ a: 'b c' }, { format : 'RFC1738' }), 'a=b+c');
|
||||
}
|
||||
|
||||
() => {
|
||||
var encodedValues = qs.stringify(
|
||||
{ a: 'b', c: ['d', 'e=f'], f: [['g'], ['h']] },
|
||||
{ encodeValuesOnly: true }
|
||||
);
|
||||
assert.equal(encodedValues,'a=b&c[0]=d&c[1]=e%3Df&f[0][0]=g&f[1][0]=h');
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
@@ -19,4 +19,4 @@
|
||||
"index.d.ts",
|
||||
"qs-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user