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

new-id

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

new-id

Creates a new id.

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

#new-id

A small module for creating unique IDs that contain a specific prefix based on the type of ID - similar to the Twilio Ids.

Format

Ids will be returned as RFC4122 v4 UUID prefixed with the user defined value in the prefixed mapping object as outlined below.

Install

npm install new-id

Usage

var options = {
    prefixes : {
        message : "MG"
    },
    strict : true
};

var new_id = require('new-id');
new_id = new new_id(options);

console.log(new_id.create('message')); // prints ==> MG993d08bbd1af4dd49dfb47eb247eb0fd

Options

  • prefixes (object) - this is an object that contains a simple key/value pair of types and prefixes. In the example above there is only one prefix message. So when that type if called the ID will be prefixed with "MG".
  • strict (boolean) - By default this is true. If there is no prefix mapping an error will be thrown indicating the type was incorrect. However, you can overwrite this when creating the object with false so even if a prefix is not found a regular (non-prefixed) id will be returned.

FAQs

Package last updated on 18 Feb 2016

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