Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 4x 4x 18x 1x 17x 17x 154x 154x 154x 17x | import { isNumber } from '../assert/is-number';
/**
* Generates a random string of length
*/
export function randomString(length: number): string {
if (!isNumber(length)) {
throw new Error('randomString must have a length argument');
}
let str = '';
for (let i = 0; i < length; i++) {
// eslint-disable-next-line: no-magic-numbers
let rand = Math.floor(Math.random() * 62);
// eslint-disable-next-line: no-magic-numbers
const charCode = rand += rand > 9 ? (rand < 36 ? 55 : 61) : 48;
str += String.fromCharCode(charCode);
}
return str;
}
|