Add timsort (#30493)

* Add timsort

* Reduce the number of overloads for timsort
This commit is contained in:
Vladimir Adamić
2018-11-19 08:32:41 -08:00
committed by Pranav Senthilnathan
parent 936d8f558c
commit f849e87482
4 changed files with 53 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
// Type definitions for timsort 0.3
// Project: https://github.com/mziccard/node-timsort
// Definitions by: Vunovati <https://github.com/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<T>(
array: T[],
compare?: (a: T, b: T) => number,
lo?: number,
hi?: number
): void;
+3
View File
@@ -0,0 +1,3 @@
import * as TimSort from 'timsort';
TimSort.sort([]); // $ExpectType void
+23
View File
@@ -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"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }