mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-22 11:57:33 +08:00
Add new options introduced in qs 2.5
This commit is contained in:
5
types/qs/index.d.ts
vendored
5
types/qs/index.d.ts
vendored
@@ -1,9 +1,10 @@
|
||||
// Type definitions for qs 6.4.0
|
||||
// Type definitions for qs 6.5.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>
|
||||
// Arturs Vonda <https://github.com/artursvonda>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export = QueryString;
|
||||
@@ -23,6 +24,7 @@ declare namespace QueryString {
|
||||
serializeDate?: (d: Date) => string;
|
||||
format?: 'RFC1738' | 'RFC3986';
|
||||
encodeValuesOnly?: boolean;
|
||||
addQueryPrefix?: boolean;
|
||||
}
|
||||
|
||||
interface IParseOptions {
|
||||
@@ -36,6 +38,7 @@ declare namespace QueryString {
|
||||
allowPrototypes?: boolean;
|
||||
parameterLimit?: number;
|
||||
strictNullHandling?: boolean;
|
||||
ignoreQueryPrefix?: boolean;
|
||||
}
|
||||
|
||||
function stringify(obj: any, options?: IStringifyOptions): string;
|
||||
|
||||
@@ -233,6 +233,11 @@ qs.parse('a=b&c=d', { delimiter: '&' });
|
||||
assert.deepEqual(parsedStrictNull, { a: null, b: '' });
|
||||
}
|
||||
|
||||
() => {
|
||||
var parsedQueryPrefix = qs.parse('?a&b=', { ignoreQueryPrefix: true });
|
||||
assert.deepEqual(parsedQueryPrefix, { a: '', b: '' });
|
||||
}
|
||||
|
||||
() => {
|
||||
var nullsSkipped = qs.stringify({ a: 'b', c: null }, { skipNulls: true });
|
||||
assert.equal(nullsSkipped, 'a=b');
|
||||
@@ -278,3 +283,7 @@ qs.parse('a=b&c=d', { delimiter: '&' });
|
||||
);
|
||||
assert.equal(encodedValues,'a=b&c[0]=d&c[1]=e%3Df&f[0][0]=g&f[1][0]=h');
|
||||
}
|
||||
|
||||
() => {
|
||||
assert.equal(qs.stringify({ a: 'b' }, { addQueryPrefix: true }), '?a=b');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user