Skip to content

Commit

Permalink
add ts definition file (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanzhi713 authored Aug 18, 2020
1 parent 5a50037 commit 26a2414
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
17 changes: 17 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Rearranges items so that all items in the [left, k] are the smallest.
* The k-th element will have the (k - left + 1)-th smallest value in [left, right].
*
* @param arr the array to partially sort (in place)
* @param k middle index for partial sorting (as defined above)
* @param left left index of the range to sort (0 by default)
* @param right right index (last index of the array by default)
* @param compare compare function
*/
export default function quickselect<T>(
arr: T[],
k: number,
left?: number,
right?: number,
compare?: (x: T, y: T) => number
): void;
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@
},
"files": [
"index.js",
"index.d.ts",
"quickselect.js"
],
"types": "index.d.ts",
"keywords": [
"selection",
"algorithm",
Expand Down

0 comments on commit 26a2414

Please sign in to comment.