@rpearce/simple-uniqueid

0.1.1 • Public • Published

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!

Package Sidebar

Install

npm i @rpearce/simple-uniqueid

Weekly Downloads

116

Version

0.1.1

License

BSD-3

Unpacked Size

6.42 kB

Total Files

6

Last publish

Collaborators

  • rpearce