Skip to content
Myr

fix collision by proxy number (#328)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Arutyunyan Artyom · committed by GitHub · parent 3b56634 · Browse files · 2 files+40 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+40 added−2 removed

  • tests:+36 added−0 removed
  • other:+4 added−2 removed

2 files+40 added−2 removed

modified:test/index.test.js+36 added
modified:index.js+4 added-2 removed
21 unmodified lines
22 poolOffset += bytes23}2425let random = bytes => {26 fillPool(bytes)26 // `-=` convert `bytes` to number to prevent `valueOf` abusing27 fillPool((bytes -= 0))28 return pool.subarray(poolOffset - bytes, poolOffset)29}3031let customRandom = (alphabet, size, getRandom) => {
33 unmodified lines
6566let customAlphabet = (alphabet, size) => customRandom(alphabet, size, random)6768let nanoid = (size = 21) => {69 // `-=` convert `size` to number to prevent `valueOf` abusing68 fillPool(size)70 fillPool((size -= 0))71 let id = ''72 // We are reading directly from the random pool to avoid creating new array73 for (let i = poolOffset - size; i < poolOffset; i++) {74 // It is incorrect to use bytes exceeding the alphabet size.
10 unmodified lines