UNPKG

@fidaktk/ids

Version:

A lightweight, dependency-efficient ID generator package for Node.js and web projects. Supports BSON `ObjectId` (compatible with MongoDB/Mongoose), UUIDv4/v5, CUID2, and URL-safe slug IDs.

7 lines (6 loc) 163 B
import { Buffer } from 'buffer'; export function getRandomBytes(length) { const buf = Buffer.alloc(length); crypto.getRandomValues(buf); return buf; }