mattiamalonni / nano-id

Nano ID Wrapper with custom functionalities

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nano-id

Nano ID wrapper with custom functionalities

Installation

npm i mattiamalonni/nano-id

Usage

import nano from 'nano-id';

const id = nano(); // 1s_JN-r7CQnSLbvr1be5y
const id = nano(5); // f01a2
const id = nano({ length: 10 }); // H7x1-8apXn
const id = nano({ alphabet: 'abcd' }); // cadcabadadbdbdcccacdb
const id = nano({ lookalike: false }); // Un-7-yYwIVufwbZeoCoFS
const id = nano({ symbols: '$@&€' }); // fil@A8a6gKZgWsdJ€i$YK

Options

Key Optional Type Default Description
length yes number 21 Length of the returned string
alphabet yes string undefined Custom alphabet
If specified, ignore other params
lowercase yes boolean | string true true: abcdefghijklmnopqrstuvwxyz
false: disabled
string: custom string
uppercase yes boolean | string true true: ABCDEFGHIJKLMNOPQRSTUVWXYZ
false: disabled
string: custom string
numbers yes boolean | string true true: 0123456789
false: disabled
string: custom string
symbols yes boolean | string true true: _-
false: disabled
string: custom string
lookalike yes boolean true If false remove lookalike charachters:
1, l, I, 0, O, o, u, v, 5, S, s, 2, Z

About

Nano ID Wrapper with custom functionalities

License:MIT License


Languages

Language:TypeScript 100.0%