0.1.1 • Published 4 years ago

@rpearce/simple-uniqueid v0.1.1

Weekly downloads
258
License
BSD-3
Repository
github
Last release
4 years ago

simple-uniqueid

All Contributors npm version npm downloads Build Status Coverage Status Maintainability

Generate simple unique ids.

This small package relies on Math.random().toString(16).slice(-4) to generate 32 unique characters with an optional string prefix.

Note: This is not a replacement for a real crypto library but is intended for small-batch use (like HTML id attributes).

Links

Installation

$ npm i @rpearce/simple-uniqueid

or

$ yarn add @rpearce/simple-uniqueid

Usage

import uniqueId from 'simple-uniqueid'

uniqueId() // "177dc3d88508b9f8bd2e69982a7d03b8"
uniqueId('myPrefix-') // "myPrefix-64f8fca9b3d96c98a267ba58cf0f9eb8"

Contributors

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!