From f849e874821050f7e4e242df35351c93beeb924a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladimir=20Adami=C4=87?= Date: Mon, 19 Nov 2018 17:32:41 +0100 Subject: [PATCH] Add timsort (#30493) * Add timsort * Reduce the number of overloads for timsort --- types/timsort/index.d.ts | 26 ++++++++++++++++++++++++++ types/timsort/timsort-tests.ts | 3 +++ types/timsort/tsconfig.json | 23 +++++++++++++++++++++++ types/timsort/tslint.json | 1 + 4 files changed, 53 insertions(+) create mode 100644 types/timsort/index.d.ts create mode 100644 types/timsort/timsort-tests.ts create mode 100644 types/timsort/tsconfig.json create mode 100644 types/timsort/tslint.json diff --git a/types/timsort/index.d.ts b/types/timsort/index.d.ts new file mode 100644 index 0000000000..7ded119384 --- /dev/null +++ b/types/timsort/index.d.ts @@ -0,0 +1,26 @@ +// Type definitions for timsort 0.3 +// Project: https://github.com/mziccard/node-timsort +// Definitions by: Vunovati +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * + * @param array - The array to sort. + * @param lo - First element in the range (inclusive). Default is 0 + * @param hi - Last element in the range. Default is last element + */ +export function sort(array: any[], lo: number, hi?: number): void; + +/** + * + * @param array - The array to sort. + * @param compare - Item comparison function. Default is alphabetical + * @param lo - First element in the range (inclusive). + * @param hi - Last element in the range. + */ +export function sort( + array: T[], + compare?: (a: T, b: T) => number, + lo?: number, + hi?: number +): void; diff --git a/types/timsort/timsort-tests.ts b/types/timsort/timsort-tests.ts new file mode 100644 index 0000000000..07cc657bba --- /dev/null +++ b/types/timsort/timsort-tests.ts @@ -0,0 +1,3 @@ +import * as TimSort from 'timsort'; + +TimSort.sort([]); // $ExpectType void diff --git a/types/timsort/tsconfig.json b/types/timsort/tsconfig.json new file mode 100644 index 0000000000..345a0e9b3a --- /dev/null +++ b/types/timsort/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "timsort-tests.ts" + ] +} diff --git a/types/timsort/tslint.json b/types/timsort/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/timsort/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }