diff --git a/index.browser.js b/index.browser.js index 8b51358c..9ec0a948 100644 --- a/index.browser.js +++ b/index.browser.js @@ -13,7 +13,7 @@ export let customRandom = (alphabet, defaultSize, getRandom) => { // `2^31 - 1` number, which exceeds the alphabet size. // For example, the bitmask for the alphabet size 30 is 31 (00011111). // `Math.clz32` is not used, because it is not available in browsers. - let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1 + let mask = (2 << Math.log2(alphabet.length - 1)) - 1 // Though, the bitmask solution is not perfect since the bytes exceeding // the alphabet size are refused. Therefore, to reliably generate the ID, // the random bytes redundancy has to be satisfied.