···11+import * as randomItem from 'random-item';
12import range from './range';
22-import sample from './sample';
3344/**
55 * Produces a random string between the inclusive `lower` and `upper` bounds. If
···2121 const start = upper ? lower : 'A';
2222 const end = upper ?? lower;
23232424- return sample(range(start, end));
2424+ return randomItem(range(start, end));
2525}
-3
source/sample.ts
···11-export default function sample<T>(array: T[]): T {
22- return array[Math.floor(Math.random() * array.length)];
33-}