cuid-range
v1.0.1
Published
Generate and validate CUID between two bounds. Useful for order-preserving pagination keys, gap insertion, or sequence IDs.
Maintainers
Readme
cuid-range
Generate and validate CUID between two bounds. Useful for order-preserving pagination keys, gap insertion, or sequence IDs.
- Alphabet:
0123456789abcdefghijklmnopqrstuvwxyz - Order: plain lexicographic (string) order
- Bounds: inclusive
- API: synchronous (returns value or throws)
Installation
npm i cuid-range
# or
pnpm add cuid-range
# or
yarn add cuid-rangeQuick Start
import { generateCuidBetween, isCuidBetween } from 'cuid-range';
// Generate an ID between two bounds (inclusive)
const id = generateCuidBetween('0a', '0c'); // e.g., "0b" or throw
// Validate that an ID lies between two bounds (inclusive)
const ok = isCuidBetween(id, '0a', '0c'); // true or throw