https://github.com/kamicane/uniquely
create unique identifiers
https://github.com/kamicane/uniquely
Last synced: 5 months ago
JSON representation
create unique identifiers
- Host: GitHub
- URL: https://github.com/kamicane/uniquely
- Owner: kamicane
- Created: 2014-07-05T12:38:11.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2016-03-24T10:47:54.000Z (over 10 years ago)
- Last Synced: 2025-09-25T18:54:19.216Z (9 months ago)
- Language: JavaScript
- Size: 129 KB
- Stars: 1
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Uniquely
Create unique identifiers.
## API
Default characters : `0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`
### id
An id based on a number.
```js
var unique = require('uniquely');
unique.id(87654); // 'Lmm'
```
### time
An unique id, from your characters, based on microtime
```js
unique.time(); // '5Pp68s5wk'
```
### random
A random id, from your characters, specified number of characters
```js
unique.random(10); // 'e90WFdthcl'
unique.random(10); // 'XnP2uvVw7r'
```
### iterator
A way to create sequential ids, using es6 iterators
```js
var it = unique.iterator();
it.next().value; // '0'
// some tens of thousands iterations later...
it.next().value; // 'aRG'
```
### create
The above functions, with your own set of characters
```js
var create = unique.create;
var abc = create('abc');
abc.id(87654); // 'cccbcacaaa'
abc.random(10); // 'acbccbcaba'
abc.time(); // 'acacccaabccbacaabaccacbacbbcbbbb'
```