Socket
Socket
Sign inDemoInstall

@chronark/prefixed-id

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chronark/prefixed-id

@chronark/prefixed-id pre_JUbF9zRGz9hrFXUyNJLXcowD9GsqCD


Version published
Weekly downloads
105
increased by23.53%
Maintainers
1
Weekly downloads
 
Created
Source

@chronark/prefixed-id

pre_JUbF9zRGz9hrFXUyNJLXcowD9GsqCD

A minimal library to generate Stripe inspired predixed ids for your application.

Works in

  • Nodejs
  • Cloudflare Workers
  • Vercel Edge

Install

npm i @chronark/prefixed-id

Usage

Nodejs


import nodeCrypto from "node:crypto"

const idGenerator = new IdGenerator({
    prefixes: {
        "user": "u",
    },
    crypto: nodeCrypto
})

console.log(idGenerator.id("user"))
// u_PtbBA7NGcYYDpae6ULWujk

WebCrypto

  • Cloudflare Workers
  • Vercel Edge
const idGenerator = new IdGenerator({
    prefixes: {
        "user": "u",
    },
    crypto: crypto // will be globally defined
})

console.log(idGenerator.id("user"))
// u_PtbBA7NGcYYDpae6ULWujk

FAQs

Package last updated on 10 Dec 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