2.0.0 • Published 7 months ago
idflow v2.0.0
# idflow
`idflow` is a lightweight, easy-to-use Node.js library for generating unique alphanumeric IDs. It allows customization of ID length, charset, formatting, and more.
## Features
- Generate unique alphanumeric IDs.
- Supports customizable length and charset.
- Prefix, suffix, and timestamp options.
- Format strings for ID generation.
- Case-sensitivity and regex support.
- Batch ID generation.
- Option to hash or salt IDs.
- Base64 and base32 encoding.
## Installation
To install the package, run:
```bash
npm install idflow
Usage
Basic ID Generation
const generator = require('idflow');
const id = generator.generate({ length: 64 });
console.log(id);
Generate ID with Custom Charset
const charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
const customId = generator.generate({ length: 128, charset });
console.log(customId);
Generate ID with Prefix and Suffix
const idWithPrefixSuffix = generator.generate({ length: 64, prefix: 'user_', suffix: '_001' });
console.log(idWithPrefixSuffix);
Generate ID with Timestamp
const idWithTimestamp = generator.generate({ length: 64, withTimestamp: true });
console.log(idWithTimestamp);
Validate ID
const isValid = generator.validateId(id, { length: 64 });
console.log(isValid);
Generate UUID
const uuid = generator.generateUUID();
console.log(uuid);
Batch ID Generation
const batch = generator.generateBatch(5, { length: 32 });
console.log(batch);
Author
Meet Thumar
2.0.0
7 months ago