Total Complexity | 1 |
Complexity/F | 1 |
Lines of Code | 16 |
Function Count | 1 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import Generator from './Base'; |
||
2 | |||
3 | /** |
||
4 | * Pick random item from the array. |
||
5 | * @param {array} options list of available options |
||
6 | * @returns {any} item |
||
7 | * @requires int |
||
8 | * @generator |
||
9 | */ |
||
10 | export default class PickGenerator extends Generator { |
||
11 | generate(array) { |
||
12 | const index = this.fatum.int(0, array.length - 1); |
||
13 | |||
14 | return array[index]; |
||
15 | } |
||
16 | } |
||
17 |