@neumatter/uid
v1.0.0
Published
Module for generating unique ids.
Downloads
1
Maintainers
Readme
Uid
Module for generating unique ids.
Table of Contents
Install
npm i @neumatter/uid
Usage
import Uid from '@neumatter/uid'
const uid = await Uid.generate()
console.log(uid) // prints [Uid => l6dnuuo9huq5I9ld95OCg9dhC8S6ugUq9]
console.log(uid.toString()) // prints l6dnuuo9huq5I9ld95OCg9dhC8S6ugUq9
console.log(uid.date) // prints 2022-08-03T13:44:30.921Z
import Uid from '@neumatter/uid'
const uid = await Uid.generate({ size: 12 })
console.log(uid) // prints [Uid => l6dwi29zOSlOAuONyClN]
console.log(uid.toString()) // prints l6dwi29zOSlOAuONyClN
console.log(uid.date) // prints 2022-08-03T17:46:30.791Z
import Uid from '@neumatter/uid'
const uid = await Uid.generate({ prefix: 'v1' })
console.log(uid) // prints [Uid => v1-l6dwkh88sSCL68UOggIZ6dhQnZRcStzRS]
console.log(uid.toString()) // prints v1-l6dwkh88sSCL68UOggIZ6dhQnZRcStzRS
console.log(uid.date) // prints 2022-08-03T17:48:23.480Z