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 🙏

© 2024 – Pkg Stats / Ryan Hefner

hyperdyperid

v1.2.0

Published

Fastest random ID and random string generation for Node.js

Downloads

662,709

Readme

hyperdyperid

Fastest random ID and random string generation for Node.js

  • str3_36 — generates random 3 character Base36 alphanumeric string.
  • str5_36 — generates random 5 character Base36 alphanumeric string.
  • str6_36 — generates random 6 character Base36 alphanumeric string.
  • str10_36 — generates random 10 character alphanumeric string.
  • str(len [, alphabet]) — generates any length random string using an alphabet. Use like str(10, '0123456789').
  • hyperid — generates "hyperid" like ID.
  • xorshift32 — iterates through pseudo random numbers using "xorshift32" algorithm. This used to be the algorithm behind Math.random() in V8, then it switched to "xorshift64".
  • randomU32(min, max) — generate a random 32-bit integer.

Usage

Install

yarn add hyperdyperid

Generate base36 10-character string:

const {str10_36} = require('hyperdyperid/lib/str10_36');

str10_36();
// lxifpmidcr
// cn41vpmtxo
// dj2u5ghp3r
// 6yro5d0g9l

Performance

Ran on Mac Mini M1.

Random ID generation:

node -v
v16.14.2
node benchmarks/main.js 
hyperdyperid xorshift32() x 241,258,490 ops/sec ±1.97% (78 runs sampled)
hyperdyperid str3_36() x 203,361,942 ops/sec ±1.57% (82 runs sampled)
hyperdyperid str5_36() x 124,134,559 ops/sec ±1.74% (85 runs sampled)
hyperdyperid str6_36() x 125,011,053 ops/sec ±2.48% (70 runs sampled)
hyperdyperid str10_36() x 19,445,199 ops/sec ±1.92% (84 runs sampled)
hyperdyperid str(5) x 5,940,801 ops/sec ±1.70% (82 runs sampled)
hyperdyperid str(10) x 2,798,758 ops/sec ±1.45% (65 runs sampled)
hyperdyperid hyperid() x 26,317,209 ops/sec ±2.61% (76 runs sampled)
hyperid x 17,018,022 ops/sec ±1.66% (84 runs sampled)
Math.random() x 72,294,752 ops/sec ±1.65% (83 runs sampled)
Math.random().toString() x 4,503,932 ops/sec ±2.68% (80 runs sampled)
nanoid x 470,470 ops/sec ±3.17% (77 runs sampled)
shortid x 41,870 ops/sec ±6.21% (67 runs sampled)
Fastest is hyperdyperid xorshift32()

Random integer generation:

node -v
v16.14.2
node benchmarks/randomU32.js 
randomU32(min, max) x 248,233,310 ops/sec ±1.91% (73 runs sampled)
Math.random() * (max - min + 1) + min x 35,034,863 ops/sec ±1.75% (81 runs sampled)
Fastest is randomU32(min, max)

License

MIT © Vadim Dalecky.