
Security News
Node.js Drops Bug Bounty Rewards After Funding Dries Up
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.
simpleflakes
Advanced tools
Fast, lightweight, and reliable distributed 64-bit ID generation with zero dependencies for Node.js.
Fast, lightweight, and reliable distributed 64-bit ID generation for Node.js Zero dependencies • TypeScript-ready • 8.8M+ ops/sec performance
Simpleflake generates unique 64-bit integers that are:
Perfect for database primary keys, distributed system IDs, and anywhere you need fast, unique identifiers.
npm install simpleflakes
const { simpleflake } = require('simpleflakes');
// Generate a unique ID
const id = simpleflake();
console.log(id); // 4234673179811182512n (BigInt)
// Convert to different formats
console.log(id.toString()); // "4234673179811182512"
console.log(id.toString(16)); // "3ac494d21e84f7b0" (hex)
console.log(id.toString(36)); // "w68acyhy50hc" (base36 - shortest)
import { simpleflake, parseSimpleflake, type SimpleflakeStruct } from 'simpleflakes';
// Generate with full type safety
const id: bigint = simpleflake();
// Parse the ID to extract timestamp and random bits
const parsed: SimpleflakeStruct = parseSimpleflake(id);
console.log(parsed.timestamp); // "1693244847123" (Unix timestamp as string)
console.log(parsed.randomBits); // "4567234" (Random component as string)
// Generate with custom timestamp and random bits
const customId = simpleflake(
Date.now(), // timestamp (default: Date.now())
12345, // random bits (default: 23-bit random)
Date.UTC(2000, 0, 1) // epoch (default: Year 2000)
);
import { binary, extractBits } from 'simpleflakes';
const id = simpleflake();
// View binary representation
console.log(binary(id));
// Output: "0011101011000100100100110100001000011110100001001111011110110000"
// Extract specific bit ranges
const timestampBits = extractBits(id, 23n, 41n); // Extract 41 bits starting at position 23
const randomBits = extractBits(id, 0n, 23n); // Extract first 23 bits
// Generate multiple IDs efficiently
function generateBatch(count) {
const ids = [];
for (let i = 0; i < count; i++) {
ids.push(simpleflake());
}
return ids;
}
const batch = generateBatch(1000);
console.log(`Generated ${batch.length} unique IDs`);
Each 64-bit simpleflake ID contains:
| <------- 41 bits -------> | <- 23 bits -> |
|---|---|
| Timestamp | Random |
| (milliseconds from epoch) | (0-8388607) |
This gives you:
This library is optimized for speed:
// Benchmark results (operations per second)
simpleflake() // ~8.8M+ ops/sec
parseSimpleflake() // ~3.9M+ ops/sec
binary() // ~26M+ ops/sec
Perfect for high-throughput applications requiring millions of IDs per second.
No coordination required between multiple ID generators:
// Perfect for database IDs - time-ordered and unique
const userId = simpleflake();
await db.users.create({ id: userId.toString(), name: "John" });
// Each service can generate IDs independently
const serviceAId = simpleflake(); // Service A
const serviceBId = simpleflake(); // Service B
// No coordination needed, guaranteed unique across services
// Generate compact URL identifiers
const shortId = simpleflake().toString(36); // "w68acyhy50hc"
const url = `https://short.ly/${shortId}`;
// Time-ordered event IDs for chronological processing
const eventId = simpleflake();
await analytics.track({ eventId, userId, action: "click" });
simpleflake(timestamp?, randomBits?, epoch?): bigintGenerates a unique 64-bit ID.
Parameters:
timestamp (number, optional): Unix timestamp in milliseconds. Default: Date.now()randomBits (number, optional): Random bits (0-8388607). Default: random 23-bit numberepoch (number, optional): Epoch start time. Default: Date.UTC(2000, 0, 1)Returns: BigInt - The generated ID
const id = simpleflake();
const customId = simpleflake(Date.now(), 12345, Date.UTC(2000, 0, 1));
parseSimpleflake(flake): SimpleflakeStructParses a simpleflake ID into its components.
Parameters:
flake (bigint | string | number): The ID to parseReturns: Object with timestamp and randomBits properties (both bigint)
const parsed = parseSimpleflake(4234673179811182512n);
console.log(parsed.timestamp); // "1693244847123"
console.log(parsed.randomBits); // "4567234"
binary(value, padding?): stringConverts a number to binary string representation.
Parameters:
value (bigint | string | number): Value to convertpadding (boolean, optional): Whether to pad to 64 bits. Default: trueReturns: String - Binary representation
console.log(binary(42n)); // "0000000000000000000000000000000000000000000000000000000000101010"
console.log(binary(42n, false)); // "101010"
extractBits(data, shift, length): bigintExtracts a portion of bits from a number.
Parameters:
data (bigint | string | number): Source datashift (bigint): Starting bit position (0-based from right)length (bigint): Number of bits to extractReturns: BigInt - Extracted bits as number
const bits = extractBits(0b11110000n, 4n, 4n); // Extract 4 bits starting at position 4
console.log(bits); // 15n (0b1111)
SIMPLEFLAKE_EPOCH: numberThe epoch start time (January 1, 2000 UTC) as Unix timestamp.
import { SIMPLEFLAKE_EPOCH } from 'simpleflakes';
console.log(SIMPLEFLAKE_EPOCH); // 946684800000
interface SimpleflakeStruct {
timestamp: bigint; // Unix timestamp as bigint (since 2000)
randomBits: bigint; // Random component as bigint
}
// Before (UUID v4)
import { v4 as uuidv4 } from 'uuid';
const id = uuidv4(); // "f47ac10b-58cc-4372-a567-0e02b2c3d479"
// After (Simpleflake)
import { simpleflake } from 'simpleflakes';
const id = simpleflake().toString(36); // "w68acyhy50hc" (shorter!)
// Simpleflake is backwards compatible with Snowflake structure
// Just different bit allocation:
// - Snowflake: 41 bits timestamp + 10 bits machine + 12 bits sequence
// - Simpleflake: 41 bits timestamp + 23 bits random
//
// *double-check epoch
| Library | Size | Time-ordered | Performance |
|---|---|---|---|
| Simpleflake | 64-bit | ✅ Yes | ⚡ 8.8M/sec |
| UUID v4 | 128-bit | ❌ No | 🔸 ~2M/sec |
| UUID v7 | 128-bit | ✅ Yes | 🔸 ~2M/sec |
| Nanoid | Variable | ❌ No | ⚡ ~5M/sec |
| KSUID | 160-bit | ✅ Yes | 🔸 ~1M/sec |
| Twitter Snowflake | 64-bit | ✅ Yes | ⚡ ~10M/sec |
| Library | Dependencies | Database-friendly | URL-friendly | Distributed |
|---|---|---|---|---|
| Simpleflake | ✅ Zero | ✅ Integer | ✅ Base36 | ✅ Yes |
| UUID v4 | ❌ crypto | ❌ String | ❌ Long hex | ✅ Yes |
| UUID v7 | ❌ crypto | ❌ String | ❌ Long hex | ✅ Yes |
| Nanoid | ✅ Zero | ❌ String | ✅ Custom | ✅ Yes |
| KSUID | ❌ crypto | ❌ String | ✅ Base62 | ✅ Yes |
| Twitter Snowflake | ❌ System clock | ✅ Integer | ✅ Base36 | ⚠️ Needs config |
git checkout -b feature/amazing-feature)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)FAQs
Fast, lightweight, and reliable distributed 64-bit ID generation with zero dependencies for Node.js.
The npm package simpleflakes receives a total of 156 weekly downloads. As such, simpleflakes popularity was classified as not popular.
We found that simpleflakes demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.