New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hyperid

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hyperid - npm Package Compare versions

Comparing version 2.0.5 to 2.1.0

11

hyperid.js

@@ -65,6 +65,13 @@ 'use strict'

var base64Id = Buffer.from(parser.parse(id)).toString('base64')
var l = base64Id.length
if (urlSafe) {
return base64Id.replace(/\+/g, '_').replace(/\//g, '-').replace(/==$/, '-')
if (base64Id[l - 2] === '=' && base64Id[l - 1] === '=') {
base64Id = base64Id.substr(0, l - 2) + '-'
}
return base64Id.replace(/\+/g, '_').replace(/\//g, '-')
}
return base64Id.replace(/==$/, '/')
if (base64Id[l - 2] === '=' && base64Id[l - 1] === '=') {
return base64Id.substr(0, l - 2) + '/'
}
return base64Id
}

@@ -71,0 +78,0 @@

3

package.json
{
"name": "hyperid",
"version": "2.0.5",
"version": "2.1.0",
"description": "Uber-fast unique id generation, for Node.js and the browser",

@@ -34,2 +34,3 @@ "main": "hyperid",

"hashids": "^1.2.2",
"nanoid": "^3.1.20",
"nid": "^1.1.0",

@@ -36,0 +37,0 @@ "pre-commit": "^1.2.2",

# hyperid
[![Build
Status](https://travis-ci.org/mcollina/hyperid.svg)](https://travis-ci.org/mcollina/hyperid)
[![Build Status](https://img.shields.io/github/workflow/status/mcollina/hyperid/CI)](https://github.com/mcollina/hyperid/actions)

@@ -10,13 +9,16 @@ Uber-fast unique id generation, for Node.js and the browser.

```
hashids process.hrtime x 282,674 ops/sec ±0.87% (95 runs sampled)
hashids counter x 561,497 ops/sec ±0.30% (98 runs sampled)
shortid x 44,641 ops/sec ±0.45% (93 runs sampled)
nid x 1,438,733 ops/sec ±0.50% (96 runs sampled)
uuid.v4 x 390,607 ops/sec ±0.24% (92 runs sampled)
uuid.v1 x 1,725,443 ops/sec ±0.11% (98 runs sampled)
hyperid - variable length x 14,534,944 ops/sec ±0.80% (93 runs sampled)
hyperid - fixed length x 14,452,901 ops/sec ±0.48% (94 runs sampled)
hashids process.hrtime x 287,412 ops/sec ±0.99% (90 runs sampled)
hashids counter x 621,430 ops/sec ±0.29% (97 runs sampled)
shortid x 41,179 ops/sec ±0.42% (90 runs sampled)
crypto.random x 383,473 ops/sec ±1.32% (90 runs sampled)
nid x 1,451,918 ops/sec ±0.23% (96 runs sampled)
uuid.v4 x 381,392 ops/sec ±0.46% (90 runs sampled)
uuid.v1 x 1,904,561 ops/sec ±0.31% (96 runs sampled)
nanoid x 2,137,111 ops/sec ±0.31% (95 runs sampled)
hyperid - variable length x 15,252,339 ops/sec ±0.79% (88 runs sampled)
hyperid - fixed length x 15,029,819 ops/sec ±0.63% (93 runs sampled)
hyperid - fixed length, url safe x 15,449,475 ops/sec ±0.49% (93 runs sampled)
```
_Note:_ Benchmark run with Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz and Node.js v12.14.2
_Note:_ Benchmark run with Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz and Node.js v14.15.1

@@ -49,11 +51,11 @@ ## Install

Returns a function to generate unique ids.
Returns a function to generate unique ids.
The function can accept one of the following parameters:
- `fixedLength: Boolean`
- `fixedLength: Boolean`
If *fixedLength* is `true` the function will always generate an id
that is 33 characters in length, by default `fixedLength` is `false`.
- `options: Object`
that is 33 characters in length, by default `fixedLength` is `false`.
- `options: Object`
If `{ fixedLength: true }` is passed in, the function will always generate an id
that is 33 characters in length, by default `fixedLength` is `false`.
If `{ urlSafe: true }` is passed in, the function will generate url safe ids.
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 `{ startFrom: <int> }` is passed in, the first counter will start from that

@@ -75,4 +77,4 @@ number, which must be between 0 and 2147483647. Fractions are discarded, only the

Decode the unique id into its two components, a `uuid` and a counter.
If you are generating *url safe* ids, you must pass `{ urlSafe: true }` as option.
Decode the unique id into its two components, a `uuid` and a counter.
If you are generating *url safe* ids, you must pass `{ urlSafe: true }` as option.
It returns:

@@ -79,0 +81,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc