Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tiny-uid

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tiny-uid

Barebones code to generate a uid of custom length

  • 1.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3K
increased by20.95%
Maintainers
1
Weekly downloads
 
Created
Source

Basic uid generator for your stuff

Intended to be used in client side apps served on the web, kept bare minimum in code size for that reason.

Uses crypto.getRandomValues when available, fallbacks to Math.random() otherwise.

collision-free generation is not guranteed. Increase length for less collision probability.

Usage

Install

npm i tiny-uid

Use

import uid from 'tiny-uid';

console.log(uid()); // > 5oylanv
console.log(uid(12)); // > a6ps30ruclh0

API

uid([length = 7])

Returns randomly generated alpha-numeric string. Optionally you can specify custom length for returned string, defaults to 7.

Note: At the moment, generated string is all lowercase, but is subject to change in future releases, should needs/use cases, require so.

Keywords

FAQs

Package last updated on 28 Jul 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc