diff --git a/types/natural-sort/index.d.ts b/types/natural-sort/index.d.ts index 4e929d4edc..3a88919a25 100644 --- a/types/natural-sort/index.d.ts +++ b/types/natural-sort/index.d.ts @@ -1,9 +1,18 @@ // Type definitions for NaturalSort // Project: https://github.com/studio-b12/natural-sort // Definitions by: Antonio Morales +// Brian Crowell // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export as namespace naturalSort; -declare function naturalSort(a: T, b: T): number; +interface Options { + /** Set to true to make the sort case-sensitive. */ + caseSensitive?: boolean; + + /** Set to 'desc' to sort in reverse. */ + direction?: 'desc' +} + +declare function naturalSort(options?: Options): (a: string | number, b: string | number) => number; export = naturalSort; diff --git a/types/natural-sort/natural-sort-tests.ts b/types/natural-sort/natural-sort-tests.ts index b336542520..6218f4e796 100644 --- a/types/natural-sort/natural-sort-tests.ts +++ b/types/natural-sort/natural-sort-tests.ts @@ -1,5 +1,8 @@ import naturalSort = require("natural-sort"); -[5, 3, 2, 4, 1].sort(naturalSort); -["a", "c", "b", "z", "w", "l"].sort(naturalSort); +['10. tenth', 'odd', 1, '', '2. second'].sort(naturalSort()); +[3, 4, 1, 5, 2].sort(naturalSort({direction: 'desc'})); + +['a', 'B'].sort(naturalSort()); +['a', 'B'].sort(naturalSort({caseSensitive: true}));