Utilities to transform, format, and generate collections of IDs efficiently in memory.
batch(generator, count)
Generates an array of count identifiers using the provided generator function:
js
import { batch, uuidv7, smart } from '@readytools/id';
// Generate 100 UUIDv7s for bulk SQL insert
const batchIds = batch(uuidv7, 100);
// Generate 25 custom smart IDs
const smartTokens = batch(() => smart('tok'), 25);format(id, fmt)
Transforms ID formatting for database storage or styling requirements:
js
import { format } from '@readytools/id';
const uuid = '018f6f89-8d2a-7140-9a3b-586b9e248b11';
// Compact format (strips hyphens) -> 32 characters
format(uuid, 'compact'); // "018f6f898d2a71409a3b586b9e248b11"
// Uppercase
format(uuid, 'uppercase'); // "018F6F89-8D2A-7140-9A3B-586B9E248B11"
// Lowercase
format(uuid, 'lowercase'); // "018f6f89-8d2a-7140-9a3b-586b9e248b11"shortId(size?)
Generates a short, human-friendly identifier using a 58-character Base58 alphabet that omits visually ambiguous characters (0, O, I, l):
js
import { shortId } from '@readytools/id';
const id = shortId(12); // Default is 12 characters
// Returns: "9xK2mPq4Rt7w"⚡ Live Playground
shortId()
Generating...
📏 Calculating...✨ Web Crypto Native