( elements: Self )
| 135 | |
| 136 | /** @internal */ |
| 137 | export const choice = <Self extends Iterable<unknown>>( |
| 138 | elements: Self |
| 139 | ) => { |
| 140 | const array = Array.fromIterable(elements) |
| 141 | return core.map( |
| 142 | array.length === 0 |
| 143 | ? core.fail(new core.NoSuchElementException("Cannot select a random element from an empty array")) |
| 144 | : randomWith((random) => random.nextIntBetween(0, array.length)), |
| 145 | (i) => array[i] |
| 146 | ) as any |
| 147 | } |
| 148 | |
| 149 | // circular with Tracer |
| 150 |
nothing calls this directly
no test coverage detected
searching dependent graphs…