forked from jbaroudi/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
shuffle-array.d.ts
42 lines (40 loc) · 1.14 KB
/
shuffle-array.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Type definitions for shuffle-array
// Project: https://github.com/pazguille/shuffle-array
// Definitions by: rhysd <https://rhysd.github.io>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module "shuffle-array" {
/**
* copy - Sets if should return a shuffled copy of the given array. By default it's a falsy value.
* rng - Specifies a custom random number generator.
*/
interface ShuffleOption {
copy?: boolean;
rng?: () => number;
}
/**
* picks - Specifies how many random elements you want to pick. By default it picks 1.
* rng - Specifies a custom random number generator.
*/
interface PickOption {
picks?: number;
rng?: () => number;
}
interface ShuffleArray {
/**
* Randomizes the order of the elements in a given array.
*
* arr - The given array.
* options - Optional configuration options.
*/
<T>(arr: T[], options?: ShuffleOption): T[];
/**
* Pick one or more random elements from the given array.
*
* arr - The given array.
* options - Optional configuration options.
*/
pick<T>(arr: T[], options?: Object): T[];
}
var shuffle: ShuffleArray;
export = shuffle;
}