npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@howionlabs/huid

v1.0.1

Published

Howion's unique identifier module for the next era

Readme

Howion's Unique IDentifier (HUID)

Howion's Unique IDentifier (HUID) for the next era of identifiers. @howionlabs/huid generates time sortable 63-bit identifiers as bigint.

Each HUID is composed of:

  • 42-bit time component (milliseconds since 2026-01-01T00:00:00.000Z)
  • 21-bit random component (cryptographically secure)

This gives compact numeric IDs that can be sorted by creation time and stored efficiently in databases.

Installation

From npm via one of:

npm install @howionlabs/huid
bun add @howionlabs/huid
yarn add @howionlabs/huid
pnpm add @howionlabs/huid

Core Functionality

Generation

import { huid } from '@howionlabs/huid'

const id = huid() // 15734368260819637n

huid() returns a new 63-bit non-negative bigint.

Decoding

import { huid, huidDecodeRandom, huidDecodeTime } from '@howionlabs/huid'

const id = huid()
const createdAt = huidDecodeTime(id) // Date
const randomPart = huidDecodeRandom(id) // bigint in [0, 2^21 - 1]

Successor and Predecessor

import { huidPred, huidSucc } from '@howionlabs/huid'

const next = huidSucc(100n) // 101n
const prev = huidPred(100n) // 99n

These helpers are useful for range boundaries and cursor style pagination.

Conversion to Binary Formats

import { huidFromBuffer, huidToBuffer } from '@howionlabs/huid'

const id = 0x0102030405060708n
const buf = huidToBuffer(id) // Buffer(8), big-endian
const decoded = huidFromBuffer(buf) // same bigint

Equivalent APIs exist for Uint8Array:

  • huidToByteArray(id)
  • huidFromByteArray(arr)

Validation

import { huidValidator } from '@howionlabs/huid'

const isValid = huidValidator({
    disallowFuture: true,
    disallowBefore: new Date('2030-01-01T00:00:00.000Z'),
    disallowAfter: 0x0102030405060708n // also accepts HUIDs
})

isValid(1n) // boolean

huidValidator(options) returns a predicate function that checks if a value is a valid HUID and optionally enforces time bounds.

Public API

Generators and navigation

  • huid(): bigint
  • huidSucc(id: bigint): bigint
  • huidPred(id: bigint): bigint

Decoders

  • huidDecodeTime(id: bigint): Date
  • huidDecodeRandom(id: bigint): bigint

Conversions

  • huidToBuffer(id: bigint): Buffer
  • huidFromBuffer(buf: Buffer): bigint
  • huidToByteArray(id: bigint): Uint8Array
  • huidFromByteArray(arr: Uint8Array): bigint

Validation

  • huidValidator(options?): (id: bigint) => boolean

Constants

  • EPOCH_2026_MS
  • EPOCH_2026_MS_N
  • MAX_TIME_MS
  • MAX_TIME_MS_N
  • MASK_21_BITS
  • MASK_21_BITS_N
  • MAX_HUID_N

Errors

The library throws HUIDError with one of these codes in error.name:

  • HUID_OVERFLOW
  • HUID_UNDERFLOW
  • INVALID_HUID
  • TIME_OVERFLOW
  • TIME_UNDERFLOW
  • TYPE_ERROR

Notes

  • Time range starts at 2026-01-01T00:00:00.000Z and supports about 139 years.
  • Maximum representable HUID is 2^63 - 1.
  • HUID values are always non-negative and fit into 8 bytes.

Drizzle example

import * as p from 'drizzle-orm/pg-core'
import { huid } from '@howionlabs/huid'

export const _huid = (colname = 'id') =>
    p.bigint(colname, { mode: 'bigint' }).$default(() => huid())

Specification

For the concise format specification and deeper rationale, see @howionlabs/huid-spec.

License

This project is licensed under the MIT License.