Skip to content
This repository has been archived by the owner on Sep 29, 2020. It is now read-only.

rpearce/simple-uniqueid

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):


Robert Pearce

💻 📖 💡 🤔 ⚠️

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