Socket
Socket
Sign inDemoInstall

generate-random-id

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    generate-random-id

A random id generator function


Version published
Weekly downloads
3
increased by200%
Maintainers
1
Install size
3.24 kB
Created
Weekly downloads
 

Readme

Source

generate-random-id

A random ID generator function.

Usage

import generateRandomId from "generate-random-id";

const options = {
  length: 12,
  set: "123456789"
}

const user = {
  name: "John Doe",
  userId: generateRandomId(options),
  isActive: true
}

DatabaseService.saveUser(user);

Params

generateRandomId accepts one param options an object with all the configurable options.

options

Range of options that can be passed to the generator function.

length

Definition: An integer signifying the length of the ID to produce.

Default: 7

set

Definition: A string of all the characters to use to produce an ID.

Default: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"

Keywords

FAQs

Last updated on 28 Aug 2021

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc