Merge pull request #17536 from zyml/qs

[qs] Update typings to 6.4.0
This commit is contained in:
Paul van Brenk
2017-06-29 10:50:10 -07:00
committed by GitHub
3 changed files with 35 additions and 6 deletions

13
types/qs/index.d.ts vendored
View File

@@ -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 {

View File

@@ -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');
}

View File

@@ -6,7 +6,7 @@
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
@@ -19,4 +19,4 @@
"index.d.ts",
"qs-tests.ts"
]
}
}