Update qs definitions to include 'sort' in its stringify options

This commit is contained in:
Belinda Teh
2017-03-06 16:43:00 -08:00
parent c38e0fecde
commit d581cd13ab
2 changed files with 8 additions and 1 deletions
+3 -1
View File
@@ -1,6 +1,7 @@
// 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>
// Definitions by: Roman Korneev <https://github.com/RWander>, Leon Yu <https://github.com/leonyu>,
// Belinda Teh <https://github.com/tehbelinda>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = QueryString;
@@ -16,6 +17,7 @@ declare namespace QueryString {
filter?: Array<string | number> | ((prefix: string, value: any) => any);
arrayFormat?: 'indices' | 'brackets' | 'repeat';
indices?: boolean;
sort?: (a: any, b: any) => number;
}
interface IParseOptions {
+5
View File
@@ -249,3 +249,8 @@ qs.parse('a=b&c=d', { delimiter: '&' });
var obj = qs.parse('a=%82%B1%82%F1%82%C9%82%BF%82%CD%81I', { decoder: decoder });
assert.deepEqual(obj, { a: 'こんにちは!' });
}
() => {
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')
}