nanoid
Advanced tools
Comparing version 3.1.31 to 3.1.32
@@ -1,7 +0,6 @@ | ||
let random = bytes => | ||
Promise.resolve(crypto.getRandomValues(new Uint8Array(bytes))) | ||
let random = async bytes => crypto.getRandomValues(new Uint8Array(bytes)) | ||
let customAlphabet = (alphabet, size) => { | ||
let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1 | ||
let step = -~((1.6 * mask * size) / alphabet.length) | ||
return () => { | ||
return async () => { | ||
let id = '' | ||
@@ -13,3 +12,3 @@ while (true) { | ||
id += alphabet[bytes[i] & mask] || '' | ||
if (id.length === size) return Promise.resolve(id) | ||
if (id.length === size) return id | ||
} | ||
@@ -19,3 +18,3 @@ } | ||
} | ||
let nanoid = (size = 21) => { | ||
let nanoid = async (size = 21) => { | ||
let id = '' | ||
@@ -35,4 +34,4 @@ let bytes = crypto.getRandomValues(new Uint8Array(size)) | ||
} | ||
return Promise.resolve(id) | ||
return id | ||
} | ||
export { nanoid, customAlphabet, random } |
{ | ||
"name": "nanoid", | ||
"version": "3.1.31", | ||
"version": "3.1.32", | ||
"description": "A tiny (130 bytes), secure URL-friendly unique string ID generator", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
25788
718