Comparing version 2.3.1 to 3.0.0
@@ -70,3 +70,3 @@ 'use strict' | ||
} | ||
return base64Id.replace(/\+/g, '_').replace(/\//g, '-') | ||
return base64Id.replace(/\+/g, '-').replace(/\//g, '_') | ||
} | ||
@@ -84,3 +84,7 @@ if (base64Id[l - 2] === '=' && base64Id[l - 1] === '=') { | ||
if (urlSafe) { | ||
id = id.replace(/-/g, '/').replace(/_/g, '+') | ||
// need to first convert the last minus to slash, | ||
// then the remaining to plus | ||
id = id.replace(/-([^-]*)$/, '/' + '$1') | ||
.replace(/-/g, '+') | ||
.replace(/_/g, '/') | ||
} | ||
@@ -87,0 +91,0 @@ |
{ | ||
"name": "hyperid", | ||
"version": "2.3.1", | ||
"version": "3.0.0", | ||
"description": "Uber-fast unique id generation, for Node.js and the browser", | ||
@@ -33,2 +33,3 @@ "main": "hyperid", | ||
"devDependencies": { | ||
"@napi-rs/uuid": "^0.1.0", | ||
"benchmark": "^2.1.4", | ||
@@ -35,0 +36,0 @@ "bloomfilter": "0.0.18", |
@@ -9,14 +9,15 @@ # hyperid | ||
``` | ||
crypto.randomUUID x 17,588,371 ops/sec ±0.86% (93 runs sampled) | ||
hashids process.hrtime x 387,622 ops/sec ±0.18% (97 runs sampled) | ||
hashids counter x 678,926 ops/sec ±0.23% (95 runs sampled) | ||
tshortid x 35,616 ops/sec ±3.56% (85 runs sampled) | ||
crypto.random x 323,029 ops/sec ±3.15% (84 runs sampled) | ||
nid x 1,387,186 ops/sec ±0.25% (99 runs sampled) | ||
uuid.v4 x 1,336,178 ops/sec ±0.34% (100 runs sampled) | ||
uuid.v1 x 2,004,247 ops/sec ±0.05% (98 runs sampled) | ||
nanoid x 2,327,169 ops/sec ±0.36% (96 runs sampled) | ||
hyperid - variable length x 21,170,011 ops/sec ±0.39% (95 runs sampled) | ||
hyperid - fixed length x 20,205,619 ops/sec ±0.17% (96 runs sampled) | ||
hyperid - fixed length, url safe x 21,195,238 ops/sec ±0.58% (94 runs sampled) | ||
crypto.randomUUID x 17,421,022 ops/sec ±1.05% (92 runs sampled) | ||
hashids process.hrtime x 381,775 ops/sec ±0.22% (95 runs sampled) | ||
hashids counter x 730,949 ops/sec ±0.23% (97 runs sampled) | ||
shortid x 34,682 ops/sec ±3.82% (83 runs sampled) | ||
crypto.random x 313,547 ops/sec ±2.88% (82 runs sampled) | ||
nid x 1,365,624 ops/sec ±0.07% (96 runs sampled) | ||
uuid.v4 x 1,313,028 ops/sec ±0.10% (97 runs sampled) | ||
napiRsUuid.v4 x 536,390 ops/sec ±0.20% (96 runs sampled) | ||
uuid.v1 x 1,999,272 ops/sec ±0.09% (98 runs sampled) | ||
nanoid x 3,808,014 ops/sec ±0.33% (95 runs sampled) | ||
hyperid - variable length x 20,197,843 ops/sec ±0.74% (94 runs sampled) | ||
hyperid - fixed length x 18,894,869 ops/sec ±0.12% (95 runs sampled) | ||
hyperid - fixed length, url safe x 20,158,778 ops/sec ±0.54% (94 runs sampled) | ||
``` | ||
@@ -63,3 +64,3 @@ | ||
that is 33 characters in length, by default `fixedLength` is `false`. | ||
If `{ urlSafe: true }` is passed in, the function will generate url safe ids. | ||
If `{ urlSafe: true }` is passed in, the function will generate url safe ids according to RFC4648. | ||
If `{ startFrom: <int> }` is passed in, the first counter will start from that | ||
@@ -66,0 +67,0 @@ number, which must be between 0 and 2147483647. Fractions are discarded, only the |
13295
285
96
12