cafe-utility 4.14.0 → 4.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.d.ts +1 -1
  2. package/index.js +2 -2
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -20,7 +20,7 @@ declare function randomIntInclusive(min: number, max: number): number;
20
20
  declare function randomBetween(min: number, max: number): number;
21
21
  declare function signedRandom(): number;
22
22
  declare function chance(threshold: number): boolean;
23
- declare function pick<T>(array: T[]): T;
23
+ declare function pick<T>(array: T[], generator?: () => number): T;
24
24
  declare function last<T>(array: T[]): T;
25
25
  declare function pickWeighted<T>(array: T[], weights: number[], randomNumber?: number): T;
26
26
  declare function sortWeighted<T>(array: T[], weights: number[]): T[];
package/index.js CHANGED
@@ -112,8 +112,8 @@ function chance(threshold) {
112
112
  return Math.random() < threshold
113
113
  }
114
114
 
115
- function pick(array) {
116
- return array[Math.floor(array.length * Math.random())]
115
+ function pick(array, generator = Math.random) {
116
+ return array[Math.floor(array.length * generator())]
117
117
  }
118
118
 
119
119
  function last(array) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cafe-utility",
3
- "version": "4.14.0",
3
+ "version": "4.15.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "exports": {