https://github.com/ex-machine/anid
Generate alphanumeric unique ids
https://github.com/ex-machine/anid
Last synced: 9 months ago
JSON representation
Generate alphanumeric unique ids
- Host: GitHub
- URL: https://github.com/ex-machine/anid
- Owner: ex-machine
- License: mit
- Created: 2018-09-17T16:20:56.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-09-17T22:44:34.000Z (over 7 years ago)
- Last Synced: 2025-06-02T20:43:29.451Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 13.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# anid
Yet another unique **a**lpha**n**umeric **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
[](https://travis-ci.com/ex-machine/anid) [](https://coveralls.io/github/ex-machine/anid)  [](https://lbesson.mit-license.org/)
## Installation
### NPM
```
npm i -S anid
```
### Yarn
```
yarn add anid
```
## API
```js
Anid([length = 8, [lowercase = false]])
```
Returns a function that generates alphanumeric unique id string.
## Usage
### Node.js
```js
const Anid = require('anid');
const anid = Anid();
const anidLowercase = Anid(null, true);
const anidLong = Anid(24);
console.log(anid()); // mXAL9KWY
console.log(anidLowercase()); // pumlrb7e
console.log(anidLong()); // NIJ174LksMaOOmykKkYce2UC
```
### Browser
```html
var anid = Anid();
var anidLowercase = Anid(null, true);
var anidLong = Anid(24);
console.log(anid()); // mXAL9KWY
console.log(anidLowercase()); // pumlrb7e
console.log(anidLong()); // NIJ174LksMaOOmykKkYce2UC
```
## License
[MIT](LICENSE)