nanoid 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Change Log
2
2
  This project adheres to [Semantic Versioning](http://semver.org/).
3
3
 
4
+ ## 0.2.2
5
+ * Reduce `nanoid/generate` size (by Anton Khlynovskiy).
6
+ * Speed up Node.js random generator.
7
+
4
8
  ## 0.2.1
5
9
  * Fix documentation (by Piper Chester).
6
10
 
package/README.md CHANGED
@@ -65,6 +65,17 @@ There are only 2 differences between Nano ID and UUID v4:
65
65
  2. Nano ID code is 2 times smaller in size than `uuid/v4` package:
66
66
  179 bytes instead of 435.
67
67
 
68
+ ## Benchmark
69
+
70
+ ```
71
+ $ ./benchmark
72
+ nanoid 375,840 ops/sec
73
+ nanoid/generate 268,747 ops/sec
74
+ uuid/v4 374,767 ops/sec
75
+ shortid 41,260 ops/sec
76
+ ```
77
+
78
+
68
79
  ## Usage
69
80
 
70
81
  ### Normal
package/format.js CHANGED
@@ -1,5 +1,3 @@
1
- var masks = [15, 31, 63, 127, 255]
2
-
3
1
  /**
4
2
  * Secure random string generator with custom alphabet.
5
3
  *
@@ -26,9 +24,7 @@ var masks = [15, 31, 63, 127, 255]
26
24
  * @name format
27
25
  */
28
26
  module.exports = function (random, alphabet, size) {
29
- var mask = masks.find(function (i) {
30
- return i >= alphabet.length - 1
31
- })
27
+ var mask = (2 << Math.log(alphabet.length - 1) / Math.LN2) - 1
32
28
  var step = Math.ceil(1.6 * mask * size / alphabet.length)
33
29
 
34
30
  var id = ''
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nanoid",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "A tiny (179 bytes), secure URL-friendly unique string ID generator",
5
5
  "keywords": [
6
6
  "uuid",
@@ -18,27 +18,27 @@
18
18
  "benchmark": "^2.1.4",
19
19
  "chalk": "^2.1.0",
20
20
  "docdash": "^0.4.0",
21
- "eslint": "^4.7.0",
21
+ "eslint": "^4.8.0",
22
22
  "eslint-config-logux": "^16.2.0",
23
23
  "eslint-config-standard": "^10.2.1",
24
24
  "eslint-plugin-es5": "^1.1.0",
25
25
  "eslint-plugin-import": "^2.7.0",
26
- "eslint-plugin-jest": "^21.1.0",
27
- "eslint-plugin-node": "^5.1.1",
26
+ "eslint-plugin-jest": "^21.2.0",
27
+ "eslint-plugin-node": "^5.2.0",
28
28
  "eslint-plugin-promise": "^3.5.0",
29
29
  "eslint-plugin-security": "^1.4.0",
30
30
  "eslint-plugin-standard": "^3.0.1",
31
31
  "html-webpack-plugin": "^2.30.1",
32
- "jest": "^21.1.0",
32
+ "jest": "^21.2.1",
33
33
  "jsdoc": "^3.5.5",
34
- "lint-staged": "^4.2.1",
34
+ "lint-staged": "^4.2.3",
35
35
  "microtime": "^2.1.6",
36
36
  "pre-commit": "^1.2.2",
37
37
  "rimraf": "^2.6.2",
38
38
  "shortid": "^2.2.8",
39
- "size-limit": "^0.11.3",
39
+ "size-limit": "^0.11.6",
40
40
  "uuid": "^3.1.0",
41
- "webpack-dev-server": "^2.8.2",
41
+ "webpack-dev-server": "^2.9.1",
42
42
  "yaspeller-ci": "^0.7.0"
43
43
  },
44
44
  "scripts": {
@@ -67,7 +67,7 @@
67
67
  },
68
68
  {
69
69
  "path": "generate.js",
70
- "limit": "196 B"
70
+ "limit": "184 B"
71
71
  }
72
72
  ],
73
73
  "lint-staged": {
package/random.js CHANGED
@@ -1,5 +1 @@
1
- var randomBytes = require('crypto').randomBytes
2
-
3
- module.exports = function (bytes) {
4
- return randomBytes(bytes)
5
- }
1
+ module.exports = require('crypto').randomBytes