https://github.com/coreh/uid2
Generate unique ids.
https://github.com/coreh/uid2
uid
Last synced: about 1 year ago
JSON representation
Generate unique ids.
- Host: GitHub
- URL: https://github.com/coreh/uid2
- Owner: coreh
- License: mit
- Created: 2013-02-05T00:46:19.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2021-10-11T20:20:57.000Z (over 4 years ago)
- Last Synced: 2025-03-30T00:08:09.215Z (about 1 year ago)
- Topics: uid
- Language: JavaScript
- Homepage:
- Size: 18.6 KB
- Stars: 43
- Watchers: 0
- Forks: 15
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY.md
- License: LICENSE
Awesome Lists containing this project
README
# uid2
[](http://badge.fury.io/js/uid2)
Generate unique ids. Pass in a `length` and it returns a `string`.
## Installation
npm install uid2
## Examples
Without a callback it is synchronous:
```js
const uid = require('uid2');
const id = uid(10);
// id => "hbswt489ts"
```
With a callback it is asynchronous:
```js
const uid = require('uid2');
uid(10, function (err, id) {
if (err) throw err;
// id => "hbswt489ts"
});
```
Imported via `uid2/promises` it returns a `Promise`:
```js
const uid = require('uid2/promises');
async function foo() {
const id = await uid(10);
// id => "hbswt489ts"
}
```
## License
MIT