epuber-stylus-source 0.54.8 → 0.56.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (465) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -1
  3. data/Rakefile +1 -1
  4. data/VERSION +1 -1
  5. data/vendor/{History.md → Changelog.md} +50 -0
  6. data/vendor/Readme.md +37 -23
  7. data/vendor/bin/stylus +1 -2
  8. data/vendor/lib/convert/css.js +1 -1
  9. data/vendor/lib/functions/acos.js +20 -0
  10. data/vendor/lib/functions/asin.js +21 -0
  11. data/vendor/lib/functions/atan.js +21 -0
  12. data/vendor/lib/functions/convert-angle.js +19 -0
  13. data/vendor/lib/functions/index.js +3 -0
  14. data/vendor/lib/functions/url.js +5 -5
  15. data/vendor/lib/lexer.js +1 -1
  16. data/vendor/lib/middleware.js +1 -2
  17. data/vendor/lib/visitor/compiler.js +2 -2
  18. data/vendor/lib/visitor/deps-resolver.js +3 -0
  19. data/vendor/node_modules/{cliui/node_modules/ansi-regex → ansi-regex}/index.d.ts +0 -0
  20. data/vendor/node_modules/ansi-regex/index.js +4 -4
  21. data/vendor/node_modules/ansi-regex/package.json +53 -51
  22. data/vendor/node_modules/ansi-regex/readme.md +35 -3
  23. data/vendor/node_modules/assertion-error/History.md +24 -0
  24. data/vendor/node_modules/{mkdirp/LICENSE → assertion-error/README.md} +22 -2
  25. data/vendor/node_modules/assertion-error/index.d.ts +11 -0
  26. data/vendor/node_modules/assertion-error/index.js +116 -0
  27. data/vendor/node_modules/assertion-error/package.json +29 -0
  28. data/vendor/node_modules/camelcase/index.d.ts +5 -3
  29. data/vendor/node_modules/camelcase/index.js +40 -18
  30. data/vendor/node_modules/camelcase/package.json +1 -1
  31. data/vendor/node_modules/camelcase/readme.md +21 -5
  32. data/vendor/node_modules/chai/CODEOWNERS +1 -0
  33. data/vendor/node_modules/chai/CODE_OF_CONDUCT.md +58 -0
  34. data/vendor/node_modules/chai/CONTRIBUTING.md +218 -0
  35. data/vendor/node_modules/chai/History.md +1059 -0
  36. data/vendor/node_modules/{should-type-adaptors → chai}/LICENSE +1 -1
  37. data/vendor/node_modules/chai/README.md +212 -0
  38. data/vendor/node_modules/chai/ReleaseNotes.md +737 -0
  39. data/vendor/node_modules/chai/bower.json +26 -0
  40. data/vendor/node_modules/chai/chai.js +11464 -0
  41. data/vendor/node_modules/chai/index.js +1 -0
  42. data/vendor/node_modules/chai/index.mjs +14 -0
  43. data/vendor/node_modules/chai/karma.conf.js +34 -0
  44. data/vendor/node_modules/chai/karma.sauce.js +41 -0
  45. data/vendor/node_modules/chai/lib/chai/assertion.js +175 -0
  46. data/vendor/node_modules/chai/lib/chai/config.js +94 -0
  47. data/vendor/node_modules/chai/lib/chai/core/assertions.js +3853 -0
  48. data/vendor/node_modules/chai/lib/chai/interface/assert.js +3113 -0
  49. data/vendor/node_modules/chai/lib/chai/interface/expect.js +47 -0
  50. data/vendor/node_modules/chai/lib/chai/interface/should.js +219 -0
  51. data/vendor/node_modules/chai/lib/chai/utils/addChainableMethod.js +152 -0
  52. data/vendor/node_modules/chai/lib/chai/utils/addLengthGuard.js +60 -0
  53. data/vendor/node_modules/chai/lib/chai/utils/addMethod.js +68 -0
  54. data/vendor/node_modules/chai/lib/chai/utils/addProperty.js +72 -0
  55. data/vendor/node_modules/chai/lib/chai/utils/compareByInspect.js +31 -0
  56. data/vendor/node_modules/chai/lib/chai/utils/expectTypes.js +51 -0
  57. data/vendor/node_modules/chai/lib/chai/utils/flag.js +33 -0
  58. data/vendor/node_modules/chai/lib/chai/utils/getActual.js +20 -0
  59. data/vendor/node_modules/chai/lib/chai/utils/getEnumerableProperties.js +26 -0
  60. data/vendor/node_modules/chai/lib/chai/utils/getMessage.js +50 -0
  61. data/vendor/node_modules/chai/lib/chai/utils/getOperator.js +55 -0
  62. data/vendor/node_modules/chai/lib/chai/utils/getOwnEnumerableProperties.js +29 -0
  63. data/vendor/node_modules/chai/lib/chai/utils/getOwnEnumerablePropertySymbols.js +27 -0
  64. data/vendor/node_modules/chai/lib/chai/utils/getProperties.js +36 -0
  65. data/vendor/node_modules/chai/lib/chai/utils/index.js +178 -0
  66. data/vendor/node_modules/chai/lib/chai/utils/inspect.js +33 -0
  67. data/vendor/node_modules/chai/lib/chai/utils/isNaN.js +26 -0
  68. data/vendor/node_modules/chai/lib/chai/utils/isProxyEnabled.js +24 -0
  69. data/vendor/node_modules/chai/lib/chai/utils/objDisplay.js +50 -0
  70. data/vendor/node_modules/chai/lib/chai/utils/overwriteChainableMethod.js +69 -0
  71. data/vendor/node_modules/chai/lib/chai/utils/overwriteMethod.js +92 -0
  72. data/vendor/node_modules/chai/lib/chai/utils/overwriteProperty.js +92 -0
  73. data/vendor/node_modules/chai/lib/chai/utils/proxify.js +147 -0
  74. data/vendor/node_modules/chai/lib/chai/utils/test.js +28 -0
  75. data/vendor/node_modules/chai/lib/chai/utils/transferFlags.js +45 -0
  76. data/vendor/node_modules/chai/lib/chai.js +92 -0
  77. data/vendor/node_modules/chai/package.json +63 -0
  78. data/vendor/node_modules/chai/register-assert.js +1 -0
  79. data/vendor/node_modules/chai/register-expect.js +1 -0
  80. data/vendor/node_modules/chai/register-should.js +1 -0
  81. data/vendor/node_modules/chai/sauce.browsers.js +106 -0
  82. data/vendor/node_modules/chalk/package.json +1 -1
  83. data/vendor/node_modules/chalk/readme.md +7 -1
  84. data/vendor/node_modules/{source-map-url → check-error}/LICENSE +1 -3
  85. data/vendor/node_modules/check-error/README.md +207 -0
  86. data/vendor/node_modules/check-error/check-error.js +176 -0
  87. data/vendor/node_modules/check-error/index.js +172 -0
  88. data/vendor/node_modules/check-error/package.json +85 -0
  89. data/vendor/node_modules/chokidar/README.md +5 -4
  90. data/vendor/node_modules/chokidar/index.js +7 -1
  91. data/vendor/node_modules/chokidar/lib/constants.js +2 -0
  92. data/vendor/node_modules/chokidar/lib/fsevents-handler.js +2 -1
  93. data/vendor/node_modules/chokidar/lib/nodefs-handler.js +9 -1
  94. data/vendor/node_modules/chokidar/package.json +15 -8
  95. data/vendor/node_modules/chokidar/types/index.d.ts +4 -3
  96. data/vendor/node_modules/css/lib/stringify/source-map-support.js +10 -3
  97. data/vendor/node_modules/css/package.json +8 -9
  98. data/vendor/node_modules/debug/LICENSE +10 -9
  99. data/vendor/node_modules/debug/README.md +116 -3
  100. data/vendor/node_modules/debug/package.json +35 -19
  101. data/vendor/node_modules/debug/src/browser.js +194 -120
  102. data/vendor/node_modules/debug/src/common.js +274 -0
  103. data/vendor/node_modules/debug/src/index.js +4 -4
  104. data/vendor/node_modules/debug/src/node.js +174 -97
  105. data/vendor/node_modules/{resolve-url → deep-eql}/LICENSE +1 -3
  106. data/vendor/node_modules/deep-eql/README.md +116 -0
  107. data/vendor/node_modules/deep-eql/deep-eql.js +833 -0
  108. data/vendor/node_modules/deep-eql/index.js +455 -0
  109. data/vendor/node_modules/deep-eql/package.json +90 -0
  110. data/vendor/node_modules/{urix → get-func-name}/LICENSE +1 -3
  111. data/vendor/node_modules/get-func-name/README.md +123 -0
  112. data/vendor/node_modules/get-func-name/get-func-name.js +48 -0
  113. data/vendor/node_modules/get-func-name/index.js +44 -0
  114. data/vendor/node_modules/get-func-name/package.json +85 -0
  115. data/vendor/node_modules/glob/README.md +3 -0
  116. data/vendor/node_modules/glob/common.js +2 -0
  117. data/vendor/node_modules/glob/glob.js +4 -5
  118. data/vendor/node_modules/glob/package.json +2 -1
  119. data/vendor/node_modules/glob/sync.js +4 -5
  120. data/vendor/node_modules/{cliui/node_modules/is-fullwidth-code-point → is-fullwidth-code-point}/index.d.ts +0 -0
  121. data/vendor/node_modules/is-fullwidth-code-point/index.js +25 -21
  122. data/vendor/node_modules/is-fullwidth-code-point/license +4 -16
  123. data/vendor/node_modules/is-fullwidth-code-point/package.json +40 -43
  124. data/vendor/node_modules/is-fullwidth-code-point/readme.md +6 -6
  125. data/vendor/node_modules/is-glob/README.md +1 -1
  126. data/vendor/node_modules/is-glob/index.js +126 -24
  127. data/vendor/node_modules/is-glob/package.json +2 -2
  128. data/vendor/node_modules/is-unicode-supported/index.d.ts +14 -0
  129. data/vendor/node_modules/is-unicode-supported/index.js +13 -0
  130. data/vendor/node_modules/{cliui/node_modules/string-width → is-unicode-supported}/license +1 -1
  131. data/vendor/node_modules/is-unicode-supported/package.json +41 -0
  132. data/vendor/node_modules/is-unicode-supported/readme.md +35 -0
  133. data/vendor/node_modules/js-yaml/CHANGELOG.md +13 -0
  134. data/vendor/node_modules/js-yaml/README.md +1 -1
  135. data/vendor/node_modules/js-yaml/dist/js-yaml.js +90 -70
  136. data/vendor/node_modules/js-yaml/dist/js-yaml.min.js +2 -2
  137. data/vendor/node_modules/js-yaml/dist/js-yaml.mjs +84 -65
  138. data/vendor/node_modules/js-yaml/index.js +17 -0
  139. data/vendor/node_modules/js-yaml/lib/schema.js +9 -9
  140. data/vendor/node_modules/js-yaml/lib/type.js +1 -0
  141. data/vendor/node_modules/js-yaml/package.json +1 -1
  142. data/vendor/node_modules/jscoverage/node_modules/ms/index.js +152 -0
  143. data/vendor/node_modules/{should-format/LICENSE → jscoverage/node_modules/ms/license.md} +1 -2
  144. data/vendor/node_modules/jscoverage/node_modules/ms/package.json +37 -0
  145. data/vendor/node_modules/jscoverage/node_modules/ms/readme.md +51 -0
  146. data/vendor/node_modules/log-symbols/index.d.ts +2 -2
  147. data/vendor/node_modules/log-symbols/index.js +3 -4
  148. data/vendor/node_modules/log-symbols/package.json +7 -5
  149. data/vendor/node_modules/log-symbols/readme.md +3 -3
  150. data/vendor/node_modules/loupe/CHANGELOG.md +5 -0
  151. data/vendor/node_modules/{cliui/node_modules/strip-ansi/license → loupe/LICENSE} +2 -2
  152. data/vendor/node_modules/loupe/README.md +63 -0
  153. data/vendor/node_modules/loupe/index.js +195 -0
  154. data/vendor/node_modules/loupe/lib/arguments.js +7 -0
  155. data/vendor/node_modules/loupe/lib/array.js +20 -0
  156. data/vendor/node_modules/loupe/lib/bigint.js +7 -0
  157. data/vendor/node_modules/loupe/lib/class.js +18 -0
  158. data/vendor/node_modules/loupe/lib/date.js +8 -0
  159. data/vendor/node_modules/loupe/lib/error.js +34 -0
  160. data/vendor/node_modules/loupe/lib/function.js +10 -0
  161. data/vendor/node_modules/loupe/lib/helpers.js +177 -0
  162. data/vendor/node_modules/loupe/lib/html.js +40 -0
  163. data/vendor/node_modules/loupe/lib/map.js +27 -0
  164. data/vendor/node_modules/loupe/lib/number.js +18 -0
  165. data/vendor/node_modules/loupe/lib/object.js +31 -0
  166. data/vendor/node_modules/loupe/lib/promise.js +16 -0
  167. data/vendor/node_modules/loupe/lib/regexp.js +8 -0
  168. data/vendor/node_modules/loupe/lib/set.js +16 -0
  169. data/vendor/node_modules/loupe/lib/string.js +29 -0
  170. data/vendor/node_modules/loupe/lib/symbol.js +6 -0
  171. data/vendor/node_modules/loupe/lib/typedarray.js +45 -0
  172. data/vendor/node_modules/loupe/loupe.js +852 -0
  173. data/vendor/node_modules/loupe/package.json +141 -0
  174. data/vendor/node_modules/minimatch/README.md +22 -1
  175. data/vendor/node_modules/minimatch/minimatch.js +93 -69
  176. data/vendor/node_modules/minimatch/package.json +6 -3
  177. data/vendor/node_modules/mocha/LICENSE +1 -1
  178. data/vendor/node_modules/mocha/README.md +1 -1
  179. data/vendor/node_modules/mocha/bin/mocha +18 -27
  180. data/vendor/node_modules/mocha/browser-entry.js +27 -20
  181. data/vendor/node_modules/mocha/lib/browser/growl.js +5 -5
  182. data/vendor/node_modules/mocha/lib/browser/parse-query.js +1 -1
  183. data/vendor/node_modules/mocha/lib/browser/progress.js +6 -6
  184. data/vendor/node_modules/mocha/lib/cli/cli.js +3 -2
  185. data/vendor/node_modules/mocha/lib/cli/config.js +7 -12
  186. data/vendor/node_modules/mocha/lib/cli/lookup-files.js +2 -8
  187. data/vendor/node_modules/mocha/lib/cli/node-flags.js +2 -5
  188. data/vendor/node_modules/mocha/lib/cli/one-and-dones.js +1 -2
  189. data/vendor/node_modules/mocha/lib/cli/run-helpers.js +15 -15
  190. data/vendor/node_modules/mocha/lib/cli/run-option-metadata.js +4 -0
  191. data/vendor/node_modules/mocha/lib/cli/run.js +13 -1
  192. data/vendor/node_modules/mocha/lib/cli/watch-run.js +3 -6
  193. data/vendor/node_modules/mocha/lib/context.js +5 -5
  194. data/vendor/node_modules/mocha/lib/errors.js +3 -3
  195. data/vendor/node_modules/mocha/lib/hook.js +9 -3
  196. data/vendor/node_modules/mocha/lib/interfaces/bdd.js +23 -20
  197. data/vendor/node_modules/mocha/lib/interfaces/common.js +7 -7
  198. data/vendor/node_modules/mocha/lib/interfaces/exports.js +1 -1
  199. data/vendor/node_modules/mocha/lib/interfaces/qunit.js +7 -7
  200. data/vendor/node_modules/mocha/lib/interfaces/tdd.js +9 -9
  201. data/vendor/node_modules/mocha/lib/mocha.js +105 -99
  202. data/vendor/node_modules/mocha/lib/nodejs/buffered-worker-pool.js +17 -1
  203. data/vendor/node_modules/mocha/lib/nodejs/esm-utils.js +124 -0
  204. data/vendor/node_modules/mocha/lib/reporters/base.js +49 -35
  205. data/vendor/node_modules/mocha/lib/reporters/doc.js +4 -4
  206. data/vendor/node_modules/mocha/lib/reporters/dot.js +5 -5
  207. data/vendor/node_modules/mocha/lib/reporters/html.js +12 -12
  208. data/vendor/node_modules/mocha/lib/reporters/json-stream.js +4 -4
  209. data/vendor/node_modules/mocha/lib/reporters/json.js +35 -10
  210. data/vendor/node_modules/mocha/lib/reporters/landing.js +5 -5
  211. data/vendor/node_modules/mocha/lib/reporters/list.js +5 -5
  212. data/vendor/node_modules/mocha/lib/reporters/markdown.js +5 -5
  213. data/vendor/node_modules/mocha/lib/reporters/min.js +1 -1
  214. data/vendor/node_modules/mocha/lib/reporters/nyan.js +16 -16
  215. data/vendor/node_modules/mocha/lib/reporters/progress.js +3 -3
  216. data/vendor/node_modules/mocha/lib/reporters/spec.js +6 -6
  217. data/vendor/node_modules/mocha/lib/reporters/tap.js +17 -17
  218. data/vendor/node_modules/mocha/lib/reporters/xunit.js +9 -9
  219. data/vendor/node_modules/mocha/lib/runnable.js +21 -21
  220. data/vendor/node_modules/mocha/lib/runner.js +63 -61
  221. data/vendor/node_modules/mocha/lib/stats-collector.js +7 -7
  222. data/vendor/node_modules/mocha/lib/suite.js +46 -75
  223. data/vendor/node_modules/mocha/lib/test.js +5 -5
  224. data/vendor/node_modules/mocha/lib/utils.js +19 -114
  225. data/vendor/node_modules/mocha/mocha-es2018.js +19794 -0
  226. data/vendor/node_modules/mocha/mocha.js +8059 -6920
  227. data/vendor/node_modules/mocha/mocha.js.map +1 -1
  228. data/vendor/node_modules/mocha/node_modules/debug/LICENSE +10 -9
  229. data/vendor/node_modules/mocha/node_modules/debug/README.md +24 -1
  230. data/vendor/node_modules/mocha/node_modules/debug/package.json +6 -6
  231. data/vendor/node_modules/mocha/node_modules/debug/src/common.js +15 -2
  232. data/vendor/node_modules/{semver → mocha/node_modules/minimatch}/LICENSE +1 -1
  233. data/vendor/node_modules/mocha/node_modules/minimatch/README.md +230 -0
  234. data/vendor/node_modules/mocha/node_modules/minimatch/minimatch.js +908 -0
  235. data/vendor/node_modules/mocha/node_modules/minimatch/package.json +31 -0
  236. data/vendor/node_modules/mocha/package.json +66 -65
  237. data/vendor/node_modules/ms/index.js +29 -19
  238. data/vendor/node_modules/ms/package.json +6 -6
  239. data/vendor/node_modules/ms/readme.md +18 -9
  240. data/vendor/node_modules/nanoid/README.md +9 -473
  241. data/vendor/node_modules/nanoid/async/index.browser.cjs +34 -0
  242. data/vendor/node_modules/nanoid/async/index.browser.js +7 -43
  243. data/vendor/node_modules/nanoid/async/index.cjs +5 -41
  244. data/vendor/node_modules/nanoid/async/index.d.ts +7 -7
  245. data/vendor/node_modules/nanoid/async/index.js +5 -41
  246. data/vendor/node_modules/nanoid/async/index.native.js +5 -36
  247. data/vendor/node_modules/nanoid/async/package.json +2 -1
  248. data/vendor/node_modules/nanoid/bin/nanoid.cjs +52 -2
  249. data/vendor/node_modules/nanoid/index.browser.cjs +37 -0
  250. data/vendor/node_modules/nanoid/index.browser.js +5 -73
  251. data/vendor/node_modules/nanoid/index.cjs +14 -49
  252. data/vendor/node_modules/nanoid/index.d.ts +9 -6
  253. data/vendor/node_modules/nanoid/index.js +14 -49
  254. data/vendor/node_modules/nanoid/non-secure/index.cjs +3 -12
  255. data/vendor/node_modules/nanoid/non-secure/index.d.ts +8 -5
  256. data/vendor/node_modules/nanoid/non-secure/index.js +3 -12
  257. data/vendor/node_modules/nanoid/package.json +14 -10
  258. data/vendor/node_modules/nanoid/url-alphabet/index.cjs +1 -4
  259. data/vendor/node_modules/nanoid/url-alphabet/index.js +1 -4
  260. data/vendor/node_modules/pathval/CHANGELOG.md +18 -0
  261. data/vendor/node_modules/pathval/LICENSE +16 -0
  262. data/vendor/node_modules/pathval/README.md +147 -0
  263. data/vendor/node_modules/pathval/index.js +301 -0
  264. data/vendor/node_modules/pathval/package.json +80 -0
  265. data/vendor/node_modules/pathval/pathval.js +1 -0
  266. data/vendor/node_modules/picomatch/CHANGELOG.md +16 -0
  267. data/vendor/node_modules/picomatch/README.md +34 -17
  268. data/vendor/node_modules/picomatch/lib/parse.js +19 -6
  269. data/vendor/node_modules/picomatch/lib/picomatch.js +34 -31
  270. data/vendor/node_modules/picomatch/lib/scan.js +8 -2
  271. data/vendor/node_modules/picomatch/package.json +1 -1
  272. data/vendor/node_modules/readdirp/index.js +11 -6
  273. data/vendor/node_modules/readdirp/package.json +1 -1
  274. data/vendor/node_modules/serialize-javascript/README.md +2 -4
  275. data/vendor/node_modules/serialize-javascript/index.js +11 -2
  276. data/vendor/node_modules/serialize-javascript/package.json +2 -2
  277. data/vendor/node_modules/source-map-resolve/LICENSE +1 -1
  278. data/vendor/node_modules/source-map-resolve/changelog.md +6 -0
  279. data/vendor/node_modules/source-map-resolve/{lib/source-map-resolve-node.js → index.js} +48 -13
  280. data/vendor/node_modules/source-map-resolve/package.json +7 -14
  281. data/vendor/node_modules/source-map-resolve/readme.md +1 -39
  282. data/vendor/node_modules/{cliui/node_modules/string-width → string-width}/index.d.ts +0 -0
  283. data/vendor/node_modules/string-width/index.js +16 -5
  284. data/vendor/node_modules/string-width/package.json +11 -10
  285. data/vendor/node_modules/string-width/readme.md +15 -7
  286. data/vendor/node_modules/{cliui/node_modules/strip-ansi → strip-ansi}/index.d.ts +0 -0
  287. data/vendor/node_modules/strip-ansi/index.js +1 -1
  288. data/vendor/node_modules/strip-ansi/package.json +52 -50
  289. data/vendor/node_modules/strip-ansi/readme.md +12 -5
  290. data/vendor/node_modules/{fsevents → type-detect}/LICENSE +1 -4
  291. data/vendor/node_modules/type-detect/README.md +228 -0
  292. data/vendor/node_modules/type-detect/index.js +378 -0
  293. data/vendor/node_modules/type-detect/package.json +1 -0
  294. data/vendor/node_modules/type-detect/type-detect.js +388 -0
  295. data/vendor/node_modules/workerpool/HISTORY.md +42 -0
  296. data/vendor/node_modules/workerpool/README.md +11 -1
  297. data/vendor/node_modules/workerpool/dist/worker.js +9 -42
  298. data/vendor/node_modules/workerpool/dist/worker.js.map +1 -1
  299. data/vendor/node_modules/workerpool/dist/workerpool.js +117 -74
  300. data/vendor/node_modules/workerpool/dist/workerpool.js.map +1 -1
  301. data/vendor/node_modules/workerpool/dist/workerpool.min.js +1 -1
  302. data/vendor/node_modules/workerpool/dist/workerpool.min.js.LICENSE.txt +3 -3
  303. data/vendor/node_modules/workerpool/dist/workerpool.min.js.map +1 -1
  304. data/vendor/node_modules/workerpool/package.json +11 -11
  305. data/vendor/node_modules/workerpool/src/Pool.js +29 -4
  306. data/vendor/node_modules/workerpool/src/WorkerHandler.js +17 -4
  307. data/vendor/node_modules/workerpool/src/generated/embeddedWorker.js +1 -1
  308. data/vendor/node_modules/workerpool/src/header.js +1 -1
  309. data/vendor/node_modules/workerpool/src/types.js +2 -1
  310. data/vendor/package-lock.json +401 -664
  311. data/vendor/package.json +7 -9
  312. metadata +139 -175
  313. data/vendor/node_modules/cliui/node_modules/ansi-regex/index.js +0 -10
  314. data/vendor/node_modules/cliui/node_modules/ansi-regex/license +0 -9
  315. data/vendor/node_modules/cliui/node_modules/ansi-regex/package.json +0 -55
  316. data/vendor/node_modules/cliui/node_modules/ansi-regex/readme.md +0 -78
  317. data/vendor/node_modules/cliui/node_modules/is-fullwidth-code-point/index.js +0 -50
  318. data/vendor/node_modules/cliui/node_modules/is-fullwidth-code-point/license +0 -9
  319. data/vendor/node_modules/cliui/node_modules/is-fullwidth-code-point/package.json +0 -42
  320. data/vendor/node_modules/cliui/node_modules/is-fullwidth-code-point/readme.md +0 -39
  321. data/vendor/node_modules/cliui/node_modules/string-width/index.js +0 -47
  322. data/vendor/node_modules/cliui/node_modules/string-width/package.json +0 -56
  323. data/vendor/node_modules/cliui/node_modules/string-width/readme.md +0 -50
  324. data/vendor/node_modules/cliui/node_modules/strip-ansi/index.js +0 -4
  325. data/vendor/node_modules/cliui/node_modules/strip-ansi/package.json +0 -54
  326. data/vendor/node_modules/cliui/node_modules/strip-ansi/readme.md +0 -46
  327. data/vendor/node_modules/css-parse/Readme.md +0 -15
  328. data/vendor/node_modules/css-parse/index.js +0 -1
  329. data/vendor/node_modules/css-parse/package.json +0 -23
  330. data/vendor/node_modules/debug/CHANGELOG.md +0 -395
  331. data/vendor/node_modules/debug/Makefile +0 -58
  332. data/vendor/node_modules/debug/karma.conf.js +0 -70
  333. data/vendor/node_modules/debug/node.js +0 -1
  334. data/vendor/node_modules/debug/src/debug.js +0 -225
  335. data/vendor/node_modules/fsevents/README.md +0 -83
  336. data/vendor/node_modules/fsevents/fsevents.d.ts +0 -46
  337. data/vendor/node_modules/fsevents/fsevents.js +0 -82
  338. data/vendor/node_modules/fsevents/fsevents.node +0 -0
  339. data/vendor/node_modules/fsevents/package.json +0 -62
  340. data/vendor/node_modules/glob/changelog.md +0 -67
  341. data/vendor/node_modules/mkdirp/CHANGELOG.md +0 -15
  342. data/vendor/node_modules/mkdirp/bin/cmd.js +0 -68
  343. data/vendor/node_modules/mkdirp/index.js +0 -31
  344. data/vendor/node_modules/mkdirp/lib/find-made.js +0 -29
  345. data/vendor/node_modules/mkdirp/lib/mkdirp-manual.js +0 -64
  346. data/vendor/node_modules/mkdirp/lib/mkdirp-native.js +0 -39
  347. data/vendor/node_modules/mkdirp/lib/opts-arg.js +0 -23
  348. data/vendor/node_modules/mkdirp/lib/path-arg.js +0 -29
  349. data/vendor/node_modules/mkdirp/lib/use-native.js +0 -10
  350. data/vendor/node_modules/mkdirp/package.json +0 -44
  351. data/vendor/node_modules/mkdirp/readme.markdown +0 -266
  352. data/vendor/node_modules/mocha/CHANGELOG.md +0 -931
  353. data/vendor/node_modules/mocha/lib/esm-utils.js +0 -58
  354. data/vendor/node_modules/mocha/node_modules/glob/LICENSE +0 -21
  355. data/vendor/node_modules/mocha/node_modules/glob/README.md +0 -375
  356. data/vendor/node_modules/mocha/node_modules/glob/changelog.md +0 -67
  357. data/vendor/node_modules/mocha/node_modules/glob/common.js +0 -240
  358. data/vendor/node_modules/mocha/node_modules/glob/glob.js +0 -790
  359. data/vendor/node_modules/mocha/node_modules/glob/package.json +0 -46
  360. data/vendor/node_modules/mocha/node_modules/glob/sync.js +0 -486
  361. data/vendor/node_modules/nanoid/CHANGELOG.md +0 -241
  362. data/vendor/node_modules/nanoid/index.dev.js +0 -105
  363. data/vendor/node_modules/nanoid/index.prod.js +0 -105
  364. data/vendor/node_modules/resolve-url/bower.json +0 -15
  365. data/vendor/node_modules/resolve-url/changelog.md +0 -15
  366. data/vendor/node_modules/resolve-url/component.json +0 -15
  367. data/vendor/node_modules/resolve-url/package.json +0 -34
  368. data/vendor/node_modules/resolve-url/readme.md +0 -83
  369. data/vendor/node_modules/resolve-url/resolve-url.js +0 -47
  370. data/vendor/node_modules/resolve-url/test/resolve-url.js +0 -70
  371. data/vendor/node_modules/semver/CHANGELOG.md +0 -70
  372. data/vendor/node_modules/semver/README.md +0 -443
  373. data/vendor/node_modules/semver/bin/semver.js +0 -174
  374. data/vendor/node_modules/semver/package.json +0 -28
  375. data/vendor/node_modules/semver/range.bnf +0 -16
  376. data/vendor/node_modules/semver/semver.js +0 -1596
  377. data/vendor/node_modules/should/CONTRIBUTING.md +0 -14
  378. data/vendor/node_modules/should/History.md +0 -554
  379. data/vendor/node_modules/should/LICENSE +0 -20
  380. data/vendor/node_modules/should/Readme.md +0 -223
  381. data/vendor/node_modules/should/as-function.js +0 -2935
  382. data/vendor/node_modules/should/cjs/should.js +0 -2962
  383. data/vendor/node_modules/should/es6/should.js +0 -2958
  384. data/vendor/node_modules/should/package.json +0 -51
  385. data/vendor/node_modules/should/should.d.ts +0 -243
  386. data/vendor/node_modules/should/should.js +0 -4371
  387. data/vendor/node_modules/should-equal/LICENSE +0 -21
  388. data/vendor/node_modules/should-equal/README.md +0 -24
  389. data/vendor/node_modules/should-equal/cjs/should-equal.js +0 -333
  390. data/vendor/node_modules/should-equal/es6/should-equal.js +0 -329
  391. data/vendor/node_modules/should-equal/package.json +0 -38
  392. data/vendor/node_modules/should-format/README.md +0 -6
  393. data/vendor/node_modules/should-format/cjs/should-format.js +0 -532
  394. data/vendor/node_modules/should-format/es6/should-format.js +0 -528
  395. data/vendor/node_modules/should-format/package.json +0 -44
  396. data/vendor/node_modules/should-type/LICENSE +0 -22
  397. data/vendor/node_modules/should-type/README.md +0 -4
  398. data/vendor/node_modules/should-type/cjs/should-type.js +0 -263
  399. data/vendor/node_modules/should-type/es6/should-type.js +0 -261
  400. data/vendor/node_modules/should-type/package.json +0 -38
  401. data/vendor/node_modules/should-type-adaptors/README.md +0 -1
  402. data/vendor/node_modules/should-type-adaptors/cjs/should-type-adaptors.js +0 -288
  403. data/vendor/node_modules/should-type-adaptors/es6/should-type-adaptors.js +0 -272
  404. data/vendor/node_modules/should-type-adaptors/package.json +0 -43
  405. data/vendor/node_modules/should-util/LICENSE +0 -21
  406. data/vendor/node_modules/should-util/README.md +0 -2
  407. data/vendor/node_modules/should-util/cjs/should-util.js +0 -50
  408. data/vendor/node_modules/should-util/es6/should-util.js +0 -42
  409. data/vendor/node_modules/should-util/package.json +0 -40
  410. data/vendor/node_modules/source-map-resolve/lib/decode-uri-component.js +0 -8
  411. data/vendor/node_modules/source-map-resolve/lib/resolve-url.js +0 -9
  412. data/vendor/node_modules/source-map-resolve/source-map-resolve.js +0 -348
  413. data/vendor/node_modules/source-map-url/changelog.md +0 -57
  414. data/vendor/node_modules/source-map-url/package.json +0 -39
  415. data/vendor/node_modules/source-map-url/readme.md +0 -97
  416. data/vendor/node_modules/source-map-url/source-map-url.js +0 -57
  417. data/vendor/node_modules/urix/index.js +0 -17
  418. data/vendor/node_modules/urix/package.json +0 -25
  419. data/vendor/node_modules/urix/readme.md +0 -46
  420. data/vendor/node_modules/urix/test/index.js +0 -43
  421. data/vendor/node_modules/wide-align/LICENSE +0 -14
  422. data/vendor/node_modules/wide-align/README.md +0 -47
  423. data/vendor/node_modules/wide-align/align.js +0 -65
  424. data/vendor/node_modules/wide-align/package.json +0 -33
  425. data/vendor/node_modules/wrap-ansi/node_modules/ansi-regex/index.d.ts +0 -37
  426. data/vendor/node_modules/wrap-ansi/node_modules/ansi-regex/index.js +0 -10
  427. data/vendor/node_modules/wrap-ansi/node_modules/ansi-regex/license +0 -9
  428. data/vendor/node_modules/wrap-ansi/node_modules/ansi-regex/package.json +0 -55
  429. data/vendor/node_modules/wrap-ansi/node_modules/ansi-regex/readme.md +0 -78
  430. data/vendor/node_modules/wrap-ansi/node_modules/is-fullwidth-code-point/index.d.ts +0 -17
  431. data/vendor/node_modules/wrap-ansi/node_modules/is-fullwidth-code-point/index.js +0 -50
  432. data/vendor/node_modules/wrap-ansi/node_modules/is-fullwidth-code-point/license +0 -9
  433. data/vendor/node_modules/wrap-ansi/node_modules/is-fullwidth-code-point/package.json +0 -42
  434. data/vendor/node_modules/wrap-ansi/node_modules/is-fullwidth-code-point/readme.md +0 -39
  435. data/vendor/node_modules/wrap-ansi/node_modules/string-width/index.d.ts +0 -29
  436. data/vendor/node_modules/wrap-ansi/node_modules/string-width/index.js +0 -47
  437. data/vendor/node_modules/wrap-ansi/node_modules/string-width/license +0 -9
  438. data/vendor/node_modules/wrap-ansi/node_modules/string-width/package.json +0 -56
  439. data/vendor/node_modules/wrap-ansi/node_modules/string-width/readme.md +0 -50
  440. data/vendor/node_modules/wrap-ansi/node_modules/strip-ansi/index.d.ts +0 -17
  441. data/vendor/node_modules/wrap-ansi/node_modules/strip-ansi/index.js +0 -4
  442. data/vendor/node_modules/wrap-ansi/node_modules/strip-ansi/license +0 -9
  443. data/vendor/node_modules/wrap-ansi/node_modules/strip-ansi/package.json +0 -54
  444. data/vendor/node_modules/wrap-ansi/node_modules/strip-ansi/readme.md +0 -46
  445. data/vendor/node_modules/yargs/node_modules/ansi-regex/index.d.ts +0 -37
  446. data/vendor/node_modules/yargs/node_modules/ansi-regex/index.js +0 -10
  447. data/vendor/node_modules/yargs/node_modules/ansi-regex/license +0 -9
  448. data/vendor/node_modules/yargs/node_modules/ansi-regex/package.json +0 -55
  449. data/vendor/node_modules/yargs/node_modules/ansi-regex/readme.md +0 -78
  450. data/vendor/node_modules/yargs/node_modules/is-fullwidth-code-point/index.d.ts +0 -17
  451. data/vendor/node_modules/yargs/node_modules/is-fullwidth-code-point/index.js +0 -50
  452. data/vendor/node_modules/yargs/node_modules/is-fullwidth-code-point/license +0 -9
  453. data/vendor/node_modules/yargs/node_modules/is-fullwidth-code-point/package.json +0 -42
  454. data/vendor/node_modules/yargs/node_modules/is-fullwidth-code-point/readme.md +0 -39
  455. data/vendor/node_modules/yargs/node_modules/string-width/index.d.ts +0 -29
  456. data/vendor/node_modules/yargs/node_modules/string-width/index.js +0 -47
  457. data/vendor/node_modules/yargs/node_modules/string-width/license +0 -9
  458. data/vendor/node_modules/yargs/node_modules/string-width/package.json +0 -56
  459. data/vendor/node_modules/yargs/node_modules/string-width/readme.md +0 -50
  460. data/vendor/node_modules/yargs/node_modules/strip-ansi/index.d.ts +0 -17
  461. data/vendor/node_modules/yargs/node_modules/strip-ansi/index.js +0 -4
  462. data/vendor/node_modules/yargs/node_modules/strip-ansi/license +0 -9
  463. data/vendor/node_modules/yargs/node_modules/strip-ansi/package.json +0 -54
  464. data/vendor/node_modules/yargs/node_modules/strip-ansi/readme.md +0 -46
  465. data/vendor/test.js +0 -31
@@ -3,20 +3,21 @@
3
3
  <img src="https://ai.github.io/nanoid/logo.svg" align="right"
4
4
  alt="Nano ID logo by Anton Lovchikov" width="180" height="94">
5
5
 
6
+ **English** | [Русский](./README.ru.md) | [简体中文](./README.zh-CN.md) | [Bahasa Indonesia](./README.id-ID.md)
7
+
6
8
  A tiny, secure, URL-friendly, unique string ID generator for JavaScript.
7
9
 
8
10
  > “An amazing level of senseless perfectionism,
9
11
  > which is simply impossible not to respect.”
10
12
 
11
- * **Small.** 108 bytes (minified and gzipped). No dependencies.
13
+ * **Small.** 130 bytes (minified and gzipped). No dependencies.
12
14
  [Size Limit] controls the size.
13
- * **Fast.** It is 60% faster than UUID.
14
- * **Safe.** It uses cryptographically strong random APIs.
15
- Can be used in clusters.
16
- * **Compact.** It uses a larger alphabet than UUID (`A-Za-z0-9_-`).
15
+ * **Fast.** It is 2 times faster than UUID.
16
+ * **Safe.** It uses hardware random generator. Can be used in clusters.
17
+ * **Short IDs.** It uses a larger alphabet than UUID (`A-Za-z0-9_-`).
17
18
  So ID size was reduced from 36 to 21 symbols.
18
19
  * **Portable.** Nano ID was ported
19
- to [14 programming languages](#other-programming-languages).
20
+ to [20 programming languages](#other-programming-languages).
20
21
 
21
22
  ```js
22
23
  import { nanoid } from 'nanoid'
@@ -34,470 +35,5 @@ Supports modern browsers, IE [with Babel], Node.js and React Native.
34
35
  alt="Sponsored by Evil Martians" width="236" height="54">
35
36
  </a>
36
37
 
37
- ## Table of Contents
38
-
39
- * [Comparison with UUID](#comparison-with-uuid)
40
- * [Benchmark](#benchmark)
41
- * [Tools](#tools)
42
- * [Security](#security)
43
- * [Usage](#usage)
44
- * [JS](#js)
45
- * [IE](#ie)
46
- * [React](#react)
47
- * [Create React App](#create-react-app)
48
- * [React Native](#react-native)
49
- * [Rollup](#rollup)
50
- * [Expo](#expo)
51
- * [PouchDB and CouchDB](#pouchdb-and-couchdb)
52
- * [Mongoose](#mongoose)
53
- * [ES Modules](#es-modules)
54
- * [Web Workers](#web-workers)
55
- * [CLI](#cli)
56
- * [Other Programming Languages](#other-programming-languages)
57
- * [API](#api)
58
- * [Async](#async)
59
- * [Non-Secure](#non-secure)
60
- * [Custom Alphabet or Size](#custom-alphabet-or-size)
61
- * [Custom Random Bytes Generator](#custom-random-bytes-generator)
62
-
63
-
64
- ## Comparison with UUID
65
-
66
- Nano ID is quite comparable to UUID v4 (random-based).
67
- It has a similar number of random bits in the ID
68
- (126 in Nano ID and 122 in UUID), so it has a similar collision probability:
69
-
70
- > For there to be a one in a billion chance of duplication,
71
- > 103 trillion version 4 IDs must be generated.
72
-
73
- There are three main differences between Nano ID and UUID v4:
74
-
75
- 1. Nano ID uses a bigger alphabet, so a similar number of random bits
76
- are packed in just 21 symbols instead of 36.
77
- 2. Nano ID code is **4.5 times less** than `uuid/v4` package:
78
- 108 bytes instead of 483.
79
- 3. Because of memory allocation tricks, Nano ID is **60%** faster than UUID.
80
-
81
-
82
- ## Benchmark
83
-
84
- ```rust
85
- $ node ./test/benchmark.js
86
- nanoid 2,280,683 ops/sec
87
- customAlphabet 1,851,117 ops/sec
88
- uuid v4 1,348,425 ops/sec
89
- uid.sync 313,306 ops/sec
90
- secure-random-string 294,161 ops/sec
91
- cuid 158,988 ops/sec
92
- shortid 37,222 ops/sec
93
-
94
- Async:
95
- async nanoid 95,500 ops/sec
96
- async customAlphabet 93,800 ops/sec
97
- async secure-random-string 90,316 ops/sec
98
- uid 85,583 ops/sec
99
-
100
- Non-secure:
101
- non-secure nanoid 2,641,654 ops/sec
102
- rndm 2,447,086 ops/sec
103
- ```
104
-
105
- Test configuration: Dell XPS 2-in-1 7390, Fedora 32, Node.js 15.1.
106
-
107
-
108
- ## Tools
109
-
110
- * [ID size calculator] shows collision probability when adjusting
111
- the ID alphabet or size.
112
- * [`nanoid-dictionary`] with popular alphabets to use with `customAlphabet`.
113
- * [`nanoid-good`] to be sure that your ID doesn’t contain any obscene words.
114
-
115
- [`nanoid-dictionary`]: https://github.com/CyberAP/nanoid-dictionary
116
- [ID size calculator]: https://zelark.github.io/nano-id-cc/
117
- [`nanoid-good`]: https://github.com/y-gagar1n/nanoid-good
118
-
119
-
120
- ## Security
121
-
122
- *See a good article about random generators theory:
123
- [Secure random values (in Node.js)]*
124
-
125
- * **Unpredictability.** Instead of using the unsafe `Math.random()`, Nano ID
126
- uses the `crypto` module in Node.js and the Web Crypto API in browsers.
127
- These modules use unpredictable hardware random generator.
128
- * **Uniformity.** `random % alphabet` is a popular mistake to make when coding
129
- an ID generator. The distribution will not be even; there will be a lower
130
- chance for some symbols to appear compared to others. So, it will reduce
131
- the number of tries when brute-forcing. Nano ID uses a [better algorithm]
132
- and is tested for uniformity.
133
-
134
- <img src="img/distribution.png" alt="Nano ID uniformity"
135
- width="340" height="135">
136
-
137
- * **Vulnerabilities:** to report a security vulnerability, please use
138
- the [Tidelift security contact](https://tidelift.com/security).
139
- Tidelift will coordinate the fix and disclosure.
140
-
141
- [Secure random values (in Node.js)]: https://gist.github.com/joepie91/7105003c3b26e65efcea63f3db82dfba
142
- [better algorithm]: https://github.com/ai/nanoid/blob/master/index.js
143
-
144
-
145
- ## Usage
146
-
147
- ### JS
148
-
149
- The main module uses URL-friendly symbols (`A-Za-z0-9_-`) and returns an ID
150
- with 21 characters (to have a collision probability similar to UUID v4).
151
-
152
- ```js
153
- import { nanoid } from 'nanoid'
154
- model.id = nanoid() //=> "V1StGXR8_Z5jdHi6B-myT"
155
- ```
156
-
157
- If you want to reduce the ID size (and increase collisions probability),
158
- you can pass the size as an argument.
159
-
160
- ```js
161
- nanoid(10) //=> "IRFa-VaY2b"
162
- ```
163
-
164
- Don’t forget to check the safety of your ID size
165
- in our [ID collision probability] calculator.
166
-
167
- You can also use a [custom alphabet](#custom-alphabet-or-size)
168
- or a [random generator](#custom-random-bytes-generator).
169
-
170
- [ID collision probability]: https://zelark.github.io/nano-id-cc/
171
-
172
-
173
- ### IE
174
-
175
- If you support IE, you need to [transpile `node_modules`] by Babel
176
- and add `crypto` alias:
177
-
178
- ```js
179
- // polyfills.js
180
- if (!window.crypto) {
181
- window.crypto = window.msCrypto
182
- }
183
- ```
184
-
185
- ```js
186
- import './polyfills.js'
187
- import { nanoid } from 'nanoid'
188
- ```
189
-
190
- [transpile `node_modules`]: https://developer.epages.com/blog/coding/how-to-transpile-node-modules-with-babel-and-webpack-in-a-monorepo/
191
-
192
-
193
- ### React
194
-
195
- **Do not** call `nanoid` in the `key` prop. In React, `key` should be consistent
196
- among renders.
197
-
198
- This is the bad example:
199
-
200
- ```jsx
201
- <Item key={nanoid()} /> /* DON’T DO IT */
202
- ```
203
-
204
- This is the good example (`id` will be generated only once):
205
-
206
- ```jsx
207
- const Element = () => {
208
- const [id] = React.useState(nanoid)
209
- return <Item key={id} />
210
- }
211
- ```
212
-
213
- If you want to use Nano ID in the `id` prop, you must set some string prefix
214
- (it is invalid for the HTML ID to start with a number).
215
-
216
- ```jsx
217
- <input id={'id' + this.id} type="text"/>
218
- ```
219
-
220
-
221
- ### Create React App
222
-
223
- Create React App has [a problem](https://github.com/ai/nanoid/issues/205)
224
- with ES modules packages.
225
-
226
- ```
227
- TypeError: (0 , _nanoid.nanoid) is not a function
228
- ```
229
-
230
- [Pull request](https://github.com/facebook/create-react-app/pull/8768) was sent,
231
- but it was still not released.
232
-
233
- Use Nano ID 2 `npm i nanoid@^2.0.0` until Create React App 4.0 release.
234
-
235
-
236
- ### React Native
237
-
238
- React Native does not have built-in random generator.
239
-
240
- 1. Check [`react-native-get-random-values`] docs and install it.
241
- 2. Import it before Nano ID.
242
-
243
- ```js
244
- import 'react-native-get-random-values'
245
- import { nanoid } from 'nanoid'
246
- ```
247
-
248
- For Expo framework see the next section.
249
-
250
- [`react-native-get-random-values`]: https://github.com/LinusU/react-native-get-random-values
251
-
252
-
253
- ### Rollup
254
-
255
- For Rollup you will need [`@rollup/plugin-replace`] to replace
256
- `process.env.NODE_ENV`:
257
-
258
- ```js
259
- plugins: [
260
- replace({
261
- 'process.env.NODE_ENV': JSON.stringify(process.env.NODE)
262
- })
263
- ]
264
- ```
265
-
266
- [`@rollup/plugin-replace`]: https://github.com/rollup/plugins/tree/master/packages/replace
267
-
268
-
269
- ### Expo
270
-
271
- If you use Expo in React Native, you need a different workaround.
272
-
273
- 1. Install [`expo-random`](https://www.npmjs.com/package/expo-random).
274
- 2. Use `nanoid/async` instead of `nanoid`.
275
- 3. Import `index.native.js` file directly.
276
-
277
- ```js
278
- import { nanoid } from 'nanoid/async/index.native'
279
-
280
- async function createUser () {
281
- user.id = await nanoid()
282
- }
283
- ```
284
-
285
- [`expo-random`]: https://www.npmjs.com/package/expo-random
286
-
287
-
288
- ### PouchDB and CouchDB
289
-
290
- In PouchDB and CouchDB, IDs can’t start with an underscore `_`.
291
- A prefix is required to prevent this issue, as Nano ID might use a `_`
292
- at the start of the ID by default.
293
-
294
- Override the default ID with the following option:
295
-
296
- ```js
297
- db.put({
298
- _id: 'id' + nanoid(),
299
-
300
- })
301
- ```
302
-
303
-
304
- ### Mongoose
305
-
306
- ```js
307
- const mySchema = new Schema({
308
- _id: {
309
- type: String,
310
- default: () => nanoid()
311
- }
312
- })
313
- ```
314
-
315
-
316
- ### ES Modules
317
-
318
- Nano ID provides ES modules. You do not need to do anything to use Nano ID
319
- as ESM in webpack, Rollup, Parcel, or Node.js.
320
-
321
- ```js
322
- import { nanoid } from 'nanoid'
323
- ```
324
-
325
- For quick hacks, you can load Nano ID from CDN. Special minified
326
- `nanoid.js` module is available on jsDelivr.
327
-
328
- Though, it is not recommended to be used in production
329
- because of the lower loading performance.
330
-
331
- ```js
332
- import { nanoid } from 'https://cdn.jsdelivr.net/npm/nanoid/nanoid.js'
333
- ```
334
-
335
-
336
- ### Web Workers
337
-
338
- Web Workers do not have access to a secure random generator.
339
-
340
- Security is important in IDs when IDs should be unpredictable.
341
- For instance, in "access by URL" link generation.
342
- If you do not need unpredictable IDs, but you need to use Web Workers,
343
- you can use the non‑secure ID generator.
344
-
345
- ```js
346
- import { nanoid } from 'nanoid/non-secure'
347
- nanoid() //=> "Uakgb_J5m9g-0JDMbcJqLJ"
348
- ```
349
-
350
- Note: non-secure IDs are more prone to collision attacks.
351
-
352
-
353
- ### CLI
354
-
355
- You can get unique ID in terminal by calling `npx nanoid`. You need only
356
- Node.js in the system. You do not need Nano ID to be installed anywhere.
357
-
358
- ```sh
359
- $ npx nanoid
360
- npx: installed 1 in 0.63s
361
- LZfXLFzPPR4NNrgjlWDxn
362
- ```
363
-
364
- If you want to change alphabet or ID size, you should use [`nanoid-cli`].
365
-
366
- [`nanoid-cli`]: https://github.com/twhitbeck/nanoid-cli
367
-
368
-
369
- ### Other Programming Languages
370
-
371
- Nano ID was ported to many languages. You can use these ports to have
372
- the same ID generator on the client and server side.
373
-
374
- * [C#](https://github.com/codeyu/nanoid-net)
375
- * [C++](https://github.com/mcmikecreations/nanoid_cpp)
376
- * [Clojure and ClojureScript](https://github.com/zelark/nano-id)
377
- * [Crystal](https://github.com/mamantoha/nanoid.cr)
378
- * [Dart](https://github.com/pd4d10/nanoid-dart)
379
- * [Deno](https://github.com/ianfabs/nanoid)
380
- * [Go](https://github.com/matoous/go-nanoid)
381
- * [Elixir](https://github.com/railsmechanic/nanoid)
382
- * [Haskell](https://github.com/4e6/nanoid-hs)
383
- * [Janet](https://sr.ht/~statianzo/janet-nanoid/)
384
- * [Java](https://github.com/aventrix/jnanoid)
385
- * [Nim](https://github.com/icyphox/nanoid.nim)
386
- * [PHP](https://github.com/hidehalo/nanoid-php)
387
- * [Python](https://github.com/puyuan/py-nanoid)
388
- with [dictionaries](https://pypi.org/project/nanoid-dictionary)
389
- * [Ruby](https://github.com/radeno/nanoid.rb)
390
- * [Rust](https://github.com/nikolay-govorov/nanoid)
391
- * [Swift](https://github.com/antiflasher/NanoID)
392
-
393
- Also, [CLI] is available to generate IDs from a command line.
394
-
395
- [CLI]: #cli
396
-
397
-
398
- ## API
399
-
400
- ### Async
401
-
402
- To generate hardware random bytes, CPU collects electromagnetic noise.
403
- In the synchronous API during the noise collection, the CPU is busy and
404
- cannot do anything useful in parallel.
405
-
406
- Using the asynchronous API of Nano ID, another code can run during
407
- the entropy collection.
408
-
409
- ```js
410
- import { nanoid } from 'nanoid/async'
411
-
412
- async function createUser () {
413
- user.id = await nanoid()
414
- }
415
- ```
416
-
417
- Unfortunately, you will lose Web Crypto API advantages in a browser
418
- if you use the asynchronous API. So, currently, in the browser, you are limited
419
- with either security or asynchronous behavior.
420
-
421
-
422
- ### Non-Secure
423
-
424
- By default, Nano ID uses hardware random bytes generation for security
425
- and low collision probability. If you are not so concerned with security
426
- and more concerned with performance, you can use the faster non-secure generator.
427
-
428
- ```js
429
- import { nanoid } from 'nanoid/non-secure'
430
- const id = nanoid() //=> "Uakgb_J5m9g-0JDMbcJqLJ"
431
- ```
432
-
433
- Note: your IDs will be more predictable and prone to collision attacks.
434
-
435
-
436
- ### Custom Alphabet or Size
437
-
438
- `customAlphabet` allows you to create `nanoid` with your own alphabet
439
- and ID size.
440
-
441
- ```js
442
- import { customAlphabet } from 'nanoid'
443
- const nanoid = customAlphabet('1234567890abcdef', 10)
444
- model.id = nanoid() //=> "4f90d13a42"
445
- ```
446
-
447
- Check the safety of your custom alphabet and ID size in our
448
- [ID collision probability] calculator. For more alphabets, check out the options
449
- in [`nanoid-dictionary`].
450
-
451
- Alphabet must contain 256 symbols or less.
452
- Otherwise, the security of the internal generator algorithm is not guaranteed.
453
-
454
- Customizable asynchronous and non-secure APIs are also available:
455
-
456
- ```js
457
- import { customAlphabet } from 'nanoid/async'
458
- const nanoid = customAlphabet('1234567890abcdef', 10)
459
- async function createUser () {
460
- user.id = await nanoid()
461
- }
462
- ```
463
-
464
- ```js
465
- import { customAlphabet } from 'nanoid/non-secure'
466
- const nanoid = customAlphabet('1234567890abcdef', 10)
467
- user.id = nanoid()
468
- ```
469
-
470
- [ID collision probability]: https://alex7kom.github.io/nano-nanoid-cc/
471
- [`nanoid-dictionary`]: https://github.com/CyberAP/nanoid-dictionary
472
-
473
-
474
- ### Custom Random Bytes Generator
475
-
476
- `customRandom` allows you to create a `nanoid` and replace alphabet
477
- and the default random bytes generator.
478
-
479
- In this example, a seed-based generator is used:
480
-
481
- ```js
482
- import { customRandom } from 'nanoid'
483
-
484
- const rng = seedrandom(seed)
485
- const nanoid = customRandom('abcdef', 10, size => {
486
- return (new Uint8Array(size)).map(() => 256 * rng())
487
- })
488
-
489
- nanoid() //=> "fbaefaadeb"
490
- ```
491
-
492
- `random` callback must accept the array size and return an array
493
- with random numbers.
494
-
495
- If you want to use the same URL-friendly symbols with `customRandom`,
496
- you can get the default alphabet using the `urlAlphabet`.
497
-
498
- ```js
499
- const { customRandom, urlAlphabet } = require('nanoid')
500
- const nanoid = customRandom(urlAlphabet, 10, random)
501
- ```
502
-
503
- Asynchronous and non-secure APIs are not available for `customRandom`.
38
+ ## Docs
39
+ Read **[full docs](https://github.com/ai/nanoid#readme)** on GitHub.
@@ -0,0 +1,34 @@
1
+ let random = async bytes => crypto.getRandomValues(new Uint8Array(bytes))
2
+ let customAlphabet = (alphabet, defaultSize = 21) => {
3
+ let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1
4
+ let step = -~((1.6 * mask * defaultSize) / alphabet.length)
5
+ return async (size = defaultSize) => {
6
+ let id = ''
7
+ while (true) {
8
+ let bytes = crypto.getRandomValues(new Uint8Array(step))
9
+ let i = step
10
+ while (i--) {
11
+ id += alphabet[bytes[i] & mask] || ''
12
+ if (id.length === size) return id
13
+ }
14
+ }
15
+ }
16
+ }
17
+ let nanoid = async (size = 21) => {
18
+ let id = ''
19
+ let bytes = crypto.getRandomValues(new Uint8Array(size))
20
+ while (size--) {
21
+ let byte = bytes[size] & 63
22
+ if (byte < 36) {
23
+ id += byte.toString(36)
24
+ } else if (byte < 62) {
25
+ id += (byte - 26).toString(36).toUpperCase()
26
+ } else if (byte < 63) {
27
+ id += '_'
28
+ } else {
29
+ id += '-'
30
+ }
31
+ }
32
+ return id
33
+ }
34
+ module.exports = { nanoid, customAlphabet, random }
@@ -1,62 +1,27 @@
1
- let random = bytes =>
2
- Promise.resolve(crypto.getRandomValues(new Uint8Array(bytes)))
3
-
4
- let customAlphabet = (alphabet, size) => {
5
- // First, a bitmask is necessary to generate the ID. The bitmask makes bytes
6
- // values closer to the alphabet size. The bitmask calculates the closest
7
- // `2^31 - 1` number, which exceeds the alphabet size.
8
- // For example, the bitmask for the alphabet size 30 is 31 (00011111).
9
- // `Math.clz32` is not used, because it is not available in browsers.
1
+ let random = async bytes => crypto.getRandomValues(new Uint8Array(bytes))
2
+ let customAlphabet = (alphabet, defaultSize = 21) => {
10
3
  let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1
11
- // Though, the bitmask solution is not perfect since the bytes exceeding
12
- // the alphabet size are refused. Therefore, to reliably generate the ID,
13
- // the random bytes redundancy has to be satisfied.
14
-
15
- // Note: every hardware random generator call is performance expensive,
16
- // because the system call for entropy collection takes a lot of time.
17
- // So, to avoid additional system calls, extra bytes are requested in advance.
18
-
19
- // Next, a step determines how many random bytes to generate.
20
- // The number of random bytes gets decided upon the ID size, mask,
21
- // alphabet size, and magic number 1.6 (using 1.6 peaks at performance
22
- // according to benchmarks).
23
-
24
- // `-~f => Math.ceil(f)` if f is a float
25
- // `-~i => i + 1` if i is an integer
26
- let step = -~((1.6 * mask * size) / alphabet.length)
27
-
28
- return () => {
4
+ let step = -~((1.6 * mask * defaultSize) / alphabet.length)
5
+ return async (size = defaultSize) => {
29
6
  let id = ''
30
7
  while (true) {
31
8
  let bytes = crypto.getRandomValues(new Uint8Array(step))
32
- // A compact alternative for `for (var i = 0; i < step; i++)`.
33
9
  let i = step
34
10
  while (i--) {
35
- // Adding `|| ''` refuses a random byte that exceeds the alphabet size.
36
11
  id += alphabet[bytes[i] & mask] || ''
37
- if (id.length === size) return Promise.resolve(id)
12
+ if (id.length === size) return id
38
13
  }
39
14
  }
40
15
  }
41
16
  }
42
-
43
- let nanoid = (size = 21) => {
17
+ let nanoid = async (size = 21) => {
44
18
  let id = ''
45
19
  let bytes = crypto.getRandomValues(new Uint8Array(size))
46
-
47
- // A compact alternative for `for (var i = 0; i < step; i++)`.
48
20
  while (size--) {
49
- // It is incorrect to use bytes exceeding the alphabet size.
50
- // The following mask reduces the random byte in the 0-255 value
51
- // range to the 0-63 value range. Therefore, adding hacks, such
52
- // as empty string fallback or magic numbers, is unneccessary because
53
- // the bitmask trims bytes down to the alphabet size.
54
21
  let byte = bytes[size] & 63
55
22
  if (byte < 36) {
56
- // `0-9a-z`
57
23
  id += byte.toString(36)
58
24
  } else if (byte < 62) {
59
- // `A-Z`
60
25
  id += (byte - 26).toString(36).toUpperCase()
61
26
  } else if (byte < 63) {
62
27
  id += '_'
@@ -64,7 +29,6 @@ let nanoid = (size = 21) => {
64
29
  id += '-'
65
30
  }
66
31
  }
67
- return Promise.resolve(id)
32
+ return id
68
33
  }
69
-
70
34
  export { nanoid, customAlphabet, random }
@@ -1,14 +1,7 @@
1
1
  let crypto = require('crypto')
2
-
3
2
  let { urlAlphabet } = require('../url-alphabet/index.cjs')
4
-
5
- // `crypto.randomFill()` is a little faster than `crypto.randomBytes()`,
6
- // because it is possible to use in combination with `Buffer.allocUnsafe()`.
7
3
  let random = bytes =>
8
4
  new Promise((resolve, reject) => {
9
- // `Buffer.allocUnsafe()` is faster because it doesn’t flush the memory.
10
- // Memory flushing is unnecessary since the buffer allocation itself resets
11
- // the memory with the new bytes.
12
5
  crypto.randomFill(Buffer.allocUnsafe(bytes), (err, buf) => {
13
6
  if (err) {
14
7
  reject(err)
@@ -17,55 +10,26 @@ let random = bytes =>
17
10
  }
18
11
  })
19
12
  })
20
-
21
- let customAlphabet = (alphabet, size) => {
22
- // First, a bitmask is necessary to generate the ID. The bitmask makes bytes
23
- // values closer to the alphabet size. The bitmask calculates the closest
24
- // `2^31 - 1` number, which exceeds the alphabet size.
25
- // For example, the bitmask for the alphabet size 30 is 31 (00011111).
13
+ let customAlphabet = (alphabet, defaultSize = 21) => {
26
14
  let mask = (2 << (31 - Math.clz32((alphabet.length - 1) | 1))) - 1
27
- // Though, the bitmask solution is not perfect since the bytes exceeding
28
- // the alphabet size are refused. Therefore, to reliably generate the ID,
29
- // the random bytes redundancy has to be satisfied.
30
-
31
- // Note: every hardware random generator call is performance expensive,
32
- // because the system call for entropy collection takes a lot of time.
33
- // So, to avoid additional system calls, extra bytes are requested in advance.
34
-
35
- // Next, a step determines how many random bytes to generate.
36
- // The number of random bytes gets decided upon the ID size, mask,
37
- // alphabet size, and magic number 1.6 (using 1.6 peaks at performance
38
- // according to benchmarks).
39
- let step = Math.ceil((1.6 * mask * size) / alphabet.length)
40
-
41
- let tick = id =>
15
+ let step = Math.ceil((1.6 * mask * defaultSize) / alphabet.length)
16
+ let tick = (id, size = defaultSize) =>
42
17
  random(step).then(bytes => {
43
- // A compact alternative for `for (var i = 0; i < step; i++)`.
44
18
  let i = step
45
19
  while (i--) {
46
- // Adding `|| ''` refuses a random byte that exceeds the alphabet size.
47
20
  id += alphabet[bytes[i] & mask] || ''
48
21
  if (id.length === size) return id
49
22
  }
50
- return tick(id)
23
+ return tick(id, size)
51
24
  })
52
-
53
- return () => tick('')
25
+ return size => tick('', size)
54
26
  }
55
-
56
27
  let nanoid = (size = 21) =>
57
28
  random(size).then(bytes => {
58
29
  let id = ''
59
- // A compact alternative for `for (var i = 0; i < step; i++)`.
60
30
  while (size--) {
61
- // It is incorrect to use bytes exceeding the alphabet size.
62
- // The following mask reduces the random byte in the 0-255 value
63
- // range to the 0-63 value range. Therefore, adding hacks, such
64
- // as empty string fallback or magic numbers, is unneccessary because
65
- // the bitmask trims bytes down to the alphabet size.
66
31
  id += urlAlphabet[bytes[size] & 63]
67
32
  }
68
33
  return id
69
34
  })
70
-
71
35
  module.exports = { nanoid, customAlphabet, random }