Intended to be used in client side apps served on the web, kept bare minimum in code size for that reason.
crypto.getRandomValues when available, fallbacks to
collision-free generation is not guranteed. Increase length for less collision probability.
npm i tiny-uid
import uid from 'tiny-uid'; console.log(uid()); // > 5oylanv console.log(uid(12)); // > a6ps30ruclh0
uid([length = 7])
Returns randomly generated alpha-numeric string. Optionally you can specify custom length for returned string, defaults to
Note: At the moment, generated string is all lowercase, but is subject to change in future releases, should needs/use cases, require so.
Barebones code to generate a uid of custom length
The npm package tiny-uid receives a total of 805 weekly downloads. As such, tiny-uid popularity was classified as not popular.
We found that tiny-uid demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.