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 | 8x 8x 1x 1x 10x 10x | import { range } from './range'; /** * Random a non-cryptographic random string from characters a-zA-Z0-9. * @param length the length of the random string * @signature randomString(length) * @example * randomString(5) // => aB92J * @category String */ export function randomString(length: number) { const characterSet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; const randomChar = () => characterSet[Math.floor(Math.random() * characterSet.length)]; return range(0, length).reduce(text => text + randomChar(), ''); } |