1.1.2 • Published 2 years ago
ufid v1.1.2
ufid
URL friendly reasonably unique ids.
Install
$ npm install --save ufid
Usage
Generate uids with only numbers and letters (both uppercase and lowercase):
const { generator } = require('ufid');
const uid = generator({ size: 10 });
uid(); // 10 characters long
uid(); // another one - also 10 characters long
uid(8); // another one 8 characters long
With custom alfabet:
const { generator } = require('ufid');
const uid = generator({ size: 12, alphabet: 'abc0123A' });
uid(); // 12 characters long, only a-c, 0-3, and A
With custom byte stream:
const { generator } = require('ufid');
const byteStream = {
next: () => Math.random() * 62
};
const uid = generator({ size: 6, byteStream });
uid(); // 6 characters long using non-secure random
License
MIT © Damian Krzeminski