@sandsoftwaresolutions/id
v0.1.0
Published
Small, dependency-free ID helpers for JavaScript and TypeScript.
Maintainers
Readme
@sandsoftwaresolutions/id
Small, dependency-free helpers for generating URL-safe IDs. Works in Node.js 18+ and browsers with Web Crypto.
Install
npm install @sandsoftwaresolutions/idUsage
import { createId, createPrefixedId } from "@sandsoftwaresolutions/id";
createId(); // "aT7kX2pQm9Ls"
createId(24); // 24-character random ID
createPrefixedId("customer"); // "customer_aT7kX2pQm9Ls"API
createId(length = 12, alphabet?)returns a random ID. The default alphabet contains letters and numbers.createPrefixedId(prefix, length = 12, alphabet?)addsprefix_to a generated ID.
length must be a positive integer, prefix cannot be empty, and a custom alphabet needs at least two characters. IDs are for application identifiers, not password generation or authorization tokens.
