oriid
Version:
Oriid β Ultra-Fast, Collision-Free Unique ID Generator
129 lines (87 loc) β’ 4.65 kB
Markdown

**Oriid** is a blazing-fast, high-throughput JavaScript library for generating **unique, 10-character alphanumeric IDs** at a rate of **20 million+ per second**, using only the characters `a-z`, `A-Z`, and `0-9`.
Traditional ID generators like MongoDBβs ObjectId or MySQLβs AUTO_INCREMENT come with limitations:
| Feature | Oriid | MongoDB ObjectId | MySQL Auto ID |
|--------------------------|-------------|------------------|----------------|
| Custom length | β
Yes (10+) | β Fixed (24 hex) | β Fixed-size integers |
| URL-safe / Alphanumeric | β
Yes | β Hex only | β Numeric only |
| High throughput | β
20M/sec+ | β οΈ Limited | β οΈ Risk of lock contention |
| No DB dependency | β
Yes | β Tied to MongoDB| β Tied to RDBMS |
| Collision resistant | β
Yes | β
Yes | β Needs locking |
| Sortable (time-based) | β
Optional | β
Yes | β
Yes |
| Works offline | β
Yes | β No | β No |
| Distributed-safe | β
Yes | β οΈ Needs config | β Hard to scale |
β
Key Benefits
- **10+ character compact IDs**
- **Base62 encoding** (aβz, AβZ, 0β9)
- **No external dependencies**
- **No collisions**, even under extreme load
- **Perfect for distributed systems**
- **Fast enough for real-time analytics, logs, and microservices**
```bash
npm install oriid
```
π Quick Start
```js
import { oriid } from "oriid";
let OrderTrackingId = oriid(); // Example: "aX8rT9LpQv"
```
π Example Output
```js
console.log(oriid()); // "bQ9xLpZrKd"
console.log(oriid()); // "Xv4Kp9AmR2"
console.log(oriid()); // "af9RWxLpO0"
```
This returns a unique 10-character ID, safe for use in:
URLs - File names - Offline devices - High-performance services
π API Reference
```js
oriid(): string
```
Returns a new **unique 10-character alphanumeric string**.
Details:
**Type**: `Function`
**Returns**: `string` β 10-character ID
**Alphabet**: `aβz`, `AβZ`, `0β9`
**Safe for**: URLs, filenames, logs, offline use
π Verify Oriid
```js
verifyOriid(id: string): boolean
```
```js
import { oriid, verifyOriid } from 'oriid';
const id = oriid();
console.log(id); // Example: "aP9Tx8LmQz"
console.log(verifyOriid(id)); // true
console.log(verifyOriid("bad-id")); // false
```
Checks whether a given string is a valid Oriid.
- β
Must be exactly 10 characters
- β
Only aβz, AβZ, 0β9 allowed
```js
verifyOriid("aP9Tx8LmQz"); // true
verifyOriid("1234567890"); // true
verifyOriid("bad-id!"); // false
verifyOriid("toolong12345"); // false
```
Oriid is perfect for high-frequency systems like logs, telemetry, real-time transactions, and distributed environments where coordination is hard. It generates short, URL-friendly, globally unique IDs β ideal for short URLs or filenames. Using 62 characters (aβz, AβZ, 0β9), Oriid can produce over 839 trillion unique 10-character IDs, enough to generate 2 million IDs per second for 13,000+ years. Unlike MongoDB ObjectId (longer, hex-based) or MySQL AUTO_INCREMENT (requires DB access and isnβt globally unique), Oriid is lightweight, in-memory, DB-independent, and safe for offline use β with no memory leaks, no database lock-in, and no performance trade-offs.
π Why Not Mongo ObjectId?
* MongoDB ObjectIds are **24-character hex strings** β **larger storage & URLs**
* Oriid IDs are **shorter, alphanumeric**, and **URL-safe**
* No database dependency or cluster configuration required
π Why Not MySQL AUTO\_INCREMENT?
* MySQLβs auto-increment requires a **database roundtrip**
* Itβs **not globally unique** (dangerous in distributed setups)
* Can't be safely merged across servers
Oriid solves these by being:
* In-memory
* Globally unique (based on time + counter)
* Independent of DB locks or sequences
**Reporting Bugs**
If you find an issue with EasyCSS, please report it via the GitHub issue tracker and via E-mail : github@jalsonic.com.
Designed, Built and Maintained by [Imran Amanat](https://www.imranamanat.com) imran@imranamanat.com and [Jalsonic Networks Teams](https://www.jalsonic.com) 2025.
A Division of [Jalsonic Networks](http://jalsonic.com) 2025.