Skip to content

ex-machine/anid

Repository files navigation

anid

Yet another unique alphanumeric id generator.

  • mixed case by default (L1kETH4t)
  • lower case option (l1keth4t)
  • string length option
  • very fast at default length (8 characters)
  • reasonably fast at maximum length (24 characters)
  • uses cryptographically insecure Math.random()
  • UMD format, works in Node.js and browsers
  • small footprint

Build StatusCoverage Statusgzip sizeMIT license

Installation

NPM

npm i -S anid 

Yarn

yarn add anid 

API

Anid([length=8,[lowercase=false]])

Returns a function that generates alphanumeric unique id string.

Usage

Node.js

constAnid=require('anid');constanid=Anid();constanidLowercase=Anid(null,true);constanidLong=Anid(24);console.log(anid());// mXAL9KWYconsole.log(anidLowercase());// pumlrb7econsole.log(anidLong());// NIJ174LksMaOOmykKkYce2UC

Browser

<scriptsrc="https://unpkg.com/anid/dist/anid.min.js"></script><script>varanid=Anid();varanidLowercase=Anid(null,true);varanidLong=Anid(24);console.log(anid());// mXAL9KWYconsole.log(anidLowercase());// pumlrb7econsole.log(anidLong());// NIJ174LksMaOOmykKkYce2UC</script>

License

MIT

About

Generate alphanumeric unique ids

Resources

License

Stars

Watchers

Forks

Packages

No packages published