Comparing version 2.1.5 to 2.1.6
@@ -39,7 +39,4 @@ /** | ||
while (i--) { | ||
var alpha = alphabet[bytes[i] & mask] | ||
if (alpha) { | ||
id += alpha | ||
if (id.length === +size) return id | ||
} | ||
id += alphabet[bytes[i] & mask] || '' | ||
if (id.length === +size) return id | ||
} | ||
@@ -46,0 +43,0 @@ return tick(id) |
# Change Log | ||
This project adheres to [Semantic Versioning](http://semver.org/). | ||
## 2.1.6 | ||
* Reduce size (by Stas Lashmanov). | ||
* Return fast mask for Node.js. | ||
## 2.1.5 | ||
@@ -5,0 +9,0 @@ * Reduce size (by Max Graey). |
@@ -30,3 +30,3 @@ /** | ||
module.exports = function (random, alphabet, size) { | ||
var mask = (2 << Math.log(alphabet.length - 1) / Math.LN2) - 1 | ||
var mask = (2 << 31 - Math.clz32((alphabet.length - 1) | 1)) - 1 | ||
var step = Math.ceil(1.6 * mask * size / alphabet.length) | ||
@@ -39,7 +39,4 @@ var id = '' | ||
while (i--) { | ||
var alpha = alphabet[bytes[i] & mask] | ||
if (alpha) { | ||
id += alpha | ||
if (id.length === +size) return id | ||
} | ||
id += alphabet[bytes[i] & mask] || '' | ||
if (id.length === +size) return id | ||
} | ||
@@ -46,0 +43,0 @@ } |
{ | ||
"name": "nanoid", | ||
"version": "2.1.5", | ||
"version": "2.1.6", | ||
"description": "A tiny (139 bytes), secure URL-friendly unique string ID generator", | ||
@@ -16,4 +16,6 @@ "keywords": [ | ||
"./index.js": "./index.browser.js", | ||
"./format.js": "./format.browser.js", | ||
"./random.js": "./random.browser.js", | ||
"./async/index.js": "./async/index.browser.js", | ||
"./async/format.js": "./async/format.browser.js", | ||
"./async/random.js": "./async/random.browser.js" | ||
@@ -20,0 +22,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26228
22
396