Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
H

hyperid

> 编程语言
Open source

Uber-fast unique id generation, for Node.js and the browser

751 stars0 likes2 views
WebsiteGitHub

About

Uber-fast unique id generation, for Node.js and the browser

hyperid

Uber-fast unique id generation, for Node.js and the browser. Here are the benchmarks:

…

Note: Benchmark run with Apple M4 Max and Node.js v24.13.0

Install

bash
npm i hyperid --save

Example

javascript
'use strict'

const hyperid = require('hyperid')
const instance = hyperid()

const id = instance()

console.log(id)
console.log(instance())
console.log(hyperid.decode(id))
console.log(hyperid.decode(instance()))

API

hyperid([fixedLength || options])

Returns a function to generate unique ids. The function can accept one of the following parameters:

  • 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 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 according to RFC4648. If { startFrom: } is passed in, the first counter will start from that number, which must be between 0 and 2147483647. Fractions are discarded, only the integer part matters. If { maxInt: } is passed in, the uuid will be re-generated once the maxInt is reached. The lesser the maxInt, higher the performance because of SMI (a V8 optimization).

instance()

Returns an unique id.

instance.uuid

The uuid used to generate the ids, it will change over time. If maxInt is provided in options, then it will regenerated every maxInt, else it will be regenerated every Math.pow(2, 31) - 1 to keep the integer a SMI (a V8 optimization).

hyperid.decode(id, [options])

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:

javascript
{
  uuid: '049b7020-c787-41bf-a1d2-a97612c11418',
  count: 1
}

This is aliased as instance.decode.

License

MIT

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

JavaScript

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言