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 | 19x 5262x 2631x 2631x 2631x 2631x 2631x 2631x 2631x | const LCG = (seed) => {
const lcg = (a) => a * 48271 % 2147483647
seed = seed ? lcg(seed) : lcg(Math.random())
return () => {
seed = lcg(seed)
return seed / 2147483648
}
}
/**
* uniqueId
*
* @param {string} [prefix] - optional prefix
* @return {string}
*/
export default (prefix, ex = 9e15) => {
const random = LCG()
const id = parseInt((random() * ex).toFixed(0), 10).toString(36)
return (prefix) ? `${prefix}-${id}` : id
}
|