Decrease size
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Andrey Sitnik · committed by Andrey Sitnik · parent c0e8f47 · Browse files · 5 files·+15 added−7 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+15 added−7 removed
- other:+15 added−7 removed
Provenance
- Commit
228b82f- Tree
2522047- Author
Andrey Sitnik <andrey@sitnik.ru>- Committer
Andrey Sitnik <andrey@sitnik.ru>- Parent
c0e8f47
5 files changed+15 added−7 removed
modified:async/index.browser.js+5 added-1 removed
123345678910116 unmodified linesvar crypto = self.crypto || self.msCrypto
var url = '_~getRandomVsCrypwhil0214563789bcfjkquvxzABDEFGHIJKLMNOPQSTUWXYZ'/* * This alphabet uses a-z A-Z 0-9 _~ symbols. * Symbols order was changed for better gzip compression. */var url = 'ModuleSymbhasOwnPr0123456789ABCDEFGHIJKLNQRTUVWXYZ_cfgijkpqtvxz~'
module.exports = function (size) { size = size || 21 var id = ''6 unmodified linesmodified:index.browser.js+5 added-1 removed
7 unmodified lines891011121213141516171819206 unmodified lines7 unmodified lines}
var crypto = self.crypto || self.msCrypto
var url = '_~getRandomVsCrypwhil0214563789bcfjkquvxzABDEFGHIJKLMNOPQSTUWXYZ'/* * This alphabet uses a-z A-Z 0-9 _~ symbols. * Symbols order was changed for better gzip compression. */var url = 'Uint8ArdomValuesObj012345679BCDEFGHIJKLMNPQRSTWXYZ_cfghkpqvwxyz~'
module.exports = function (size) { size = size || 21 var id = ''6 unmodified linesmodified:package.json+2 added-2 removed
60 unmodified lines61 },62 "size-limit": [63 {64 "path": "index.js",65- "limit": "143 B"65+ "limit": "142 B"66 },67 {68 "path": "generate.js",69 "limit": "177 B"3 unmodified lines73 "limit": "110 B"74 },75 {76 "path": "async/index.js",77- "limit": "155 B"77+ "limit": "154 B"78 },79 {80 "path": "async/generate.js",81 "limit": "198 B"96 unmodified linesmodified:README.md+2 added-2 removed
3 unmodified lines4 alt="Nano ID logo by Anton Lovchikov" width="180" height="94">5 6 A tiny, secure, URL-friendly, unique string ID generator for JavaScript.7 8-* **Small.** 143 bytes (minified and gzipped). No dependencies.8+* **Small.** 142 bytes (minified and gzipped). No dependencies.9 It uses [Size Limit] to control size.10 * **Safe.** It uses cryptographically strong random APIs11 and tests distribution of symbols.12 * **Fast.** It’s 16% faster than UUID.58 unmodified lines71 72 1. Nano ID uses a bigger alphabet, so a similar number of random bits73 are packed in just 21 symbols instead of 36.74 2. Nano ID code is 3 times less than `uuid/v4` package:75- 143 bytes instead of 435.75+ 142 bytes instead of 435.76 77 78 ## Benchmark79 210 unmodified linesmodified:url.js+1 added-1 removed
10 unmodified lines11121314151510 unmodified lines * const url = require('nanoid/url') * generate(url, 10) //=> "Uakgb_J5m9" */module.exports = 'functio_~0123456789abdeghjklmpqrsvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' 'SymboljecthasOwnPr0123456789ABCDEFGHIJKLMNQRTUVWXYZ_dfgikpquvxz~'