short-unique-id
Generate random or sequential UUID of any length
Last updated 7 years ago by jeanlescure .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ npm install short-unique-id 
SYNC missed versions from official npm registry.

Short Unique ID (UUID) Generating Library

CD Try short-unique-id on RunKit NPM Downloads

3 Contributors

Documentation and Online Short UUID Generator

You can find the docs and online generator at:

https://shortunique.id

What is the probability of generating the same id again?

This largely depends on the given dictionary and the selected UUID length.

Out of the box this library provides a shuffled dictionary of digits from 0 to 9, as well as the alphabet from a to z both in UPPER and lower case, with a default UUID length of 6. That gives you a total of 56,800,235,584 possible UUIDs.

So, given the previous values, the probability of generating a duplicate in 1,000,000 rounds is ~0.00000002, or about 1 in 50,000,000.

If you change the dictionary and/or the UUID length then we have provided the function collisionProbability() function to calculate the probability of hitting a duplicate in a given number of rounds (a collision) and the function uniqueness() which provides a score (from 0 to 1) to rate the "quality" of the combination of given dictionary and UUID length (the closer to 1, higher the uniqueness and thus better the quality).

To find out more about the math behind these functions please refer to the API Reference.

V3.x

Version 3.0 is a re-write of this library aiming to use Deno as the driving force of the development and distribution of Short Unique ID.

We did this by separating the Deno compatible typescript logic into a git submodule which gets bundled for the rest of the platforms by the scripts within the package.json in this repo.

Another reason for the re-write was to define a new license for the source code within this repo, the Apache 2.0 license.

"Deno" who? what?

Ryan Dahl, creator of Node.js, has spent the last couple of years working on Deno, a new runtime for JavaScript that is supposed to fix all the inherent problems of Node.

We have tried it out and are convinced that Deno is stable enough and delivers on all expectations we could have.

For more info check out this detailed look at Deno from LogRocket's blog.

Acknowledgement and platform support

This repo and npm package started as a straight up manual transpilation to ES6 of the short-uid npm package by Ankit Kuwadekar.

image depicting over 5000 weekly npm downloads

Since this package is now reporting between 4k and 5k+ npm weekly downloads, we've gone ahead and re-written the whole of it in TypeScript and made sure to package lib and dist modules compatible with Deno, Node.js and all major Browsers.

Development

Clone this repo (including submodules):

# SSH
git clone --recurse-submodules git@github.com:jeanlescure/short-unique-id.git

# HTTPS
git clone --recurse-submodules https://github.com/jeanlescure/short-unique-id.git

Tests run using Deno:

yarn test

Using airbnb rules for tslint:

yarn lint

Build

In order to publish the latest changes you must build the library and distribution files:

yarn lib:build
yarn dist:build

IMPORTANT: The dist:build script depends on the files generated by lib:build.

Contributors ✨

Thanks goes to these wonderful people (emoji key):

💻
🚧 💻 🖋 📖 ⚠️
💻
💻
💻 👀
💻
💻
🤔

This project follows the all-contributors specification. Contributions of any kind welcome!

License

Copyright (c) 2018-2020 Short Unique ID Contributors.
Licensed under the Apache License 2.0.

Current Tags

  • 5.3.2                                ...           latest (2 years ago)
  • 3.0.0-rc2                                ...           next (7 years ago)

46 Versions

  • 5.3.2                                ...           2 years ago
  • 5.3.0                                ...           2 years ago
  • 5.2.2                                ...           2 years ago
  • 5.2.0                                ...           3 years ago
  • 5.1.1                                ...           3 years ago
  • 5.1.0                                ...           3 years ago
  • 5.0.4                                ...           3 years ago
  • 5.0.3                                ...           3 years ago
  • 5.0.2                                ...           3 years ago
  • 5.0.1                                ...           3 years ago
  • 5.0.0                                ...           3 years ago
  • 4.4.4                                ...           5 years ago
  • 4.4.2                                ...           5 years ago
  • 4.4.0                                ...           5 years ago
  • 4.3.8                                ...           5 years ago
  • 4.3.6                                ...           5 years ago
  • 4.3.4                                ...           5 years ago
  • 4.3.3                                ...           6 years ago
  • 4.3.2                                ...           6 years ago
  • 4.3.1                                ...           6 years ago
  • 4.3.0                                ...           6 years ago
  • 4.2.1                                ...           6 years ago
  • 4.2.0                                ...           6 years ago
  • 4.0.2                                ...           6 years ago
  • 3.2.3                                ...           6 years ago
  • 3.2.0                                ...           6 years ago
  • 3.0.5                                ...           6 years ago
  • 3.0.4                                ...           6 years ago
  • 3.0.3                                ...           6 years ago
  • 3.0.2                                ...           7 years ago
  • 3.0.1                                ...           7 years ago
  • 3.0.0                                ...           7 years ago
  • 3.0.0-rc2                                ...           7 years ago
  • 3.0.0-rc1                                ...           7 years ago
  • 3.0.0-alpha                                ...           7 years ago
  • 2.0.7                                ...           7 years ago
  • 2.0.6                                ...           7 years ago
  • 2.0.5                                ...           7 years ago
  • 2.0.4                                ...           7 years ago
  • 2.0.2                                ...           7 years ago
  • 2.0.1                                ...           7 years ago
  • 2.0.0                                ...           7 years ago
  • 1.1.1                                ...           9 years ago
  • 1.1.0                                ...           10 years ago
  • 1.0.1                                ...           10 years ago
  • 1.0.0                                ...           10 years ago
Maintainers (1)
Downloads
Total 148
Today 0
This Week 0
This Month 137
Last Day 0
Last Week 4
Last Month 11
Dependencies (0)
None
Dev Dependencies (8)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE