Socket
Book a DemoInstallSign in
Socket

stripe-id-generator

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

stripe-id-generator

Generates random ids with a prefix (a la Stripe)

0.1.2
latest
Source
npmnpm
Version published
Weekly downloads
64
-44.35%
Maintainers
1
Weekly downloads
 
Created
Source

stripe-id-generator

Build Status Coverage Status styled with prettier

Generates random ids with a prefix (a la Stripe)

Installing

npm i stripe-id-generator # or
yarn add stripe-id-generator

Using

Simple case:

const IdGenerator = require('stripe-id-generator');

const generator = new IdGenerator();
const id = generator.new('cus');

console.log(id); // cus_lO1DEQWBbQAACfHO

Predefined set of allowed prefixes (to avoid mistakes):

const IdGenerator = require('stripe-id-generator');

const generator = new IdGenerator(['cus', 'con']);
const id = generator.new('cus');

console.log(id); // cus_lO1DEQWBbQAACfHO

generator.new('cli'); // throws

To get a uid (id with a given length and without prefix):

const IdGenerator = require('stripe-id-generator');

const generator = new IdGenerator(['cus', 'con']);
const id = generator.newUid(10);

console.log(id); // lO1DEQWBbQ

Author

Fork from Auth0

License

This project is licensed under the MIT license. See the LICENSE file for more info.

FAQs

Package last updated on 21 Sep 2019

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.