npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@liorandb/core

v1.2.6

Published

LioranDB Core Module – Lightweight, local-first, peer-to-peer database management for Node.js.

Readme

@liorandb/core

LioranDB Core is an encrypted, local-first embedded database for Node.js with a Mongo-like collection API, secondary indexes, schema migration hooks, WAL-backed transactions, and TypeScript-friendly ergonomics.

Install

npm install @liorandb/core

Quick Start

import { LioranManager } from "@liorandb/core";

const manager = new LioranManager({
  rootPath: "./data",
  encryptionKey: "my-secret"
});

const db = await manager.db("app");
const users = db.collection<{ name: string; email: string; age: number }>("users");

await users.insertOne({
  name: "Ava",
  email: "[email protected]",
  age: 25
});

await db.createIndex("users", "email", { unique: true });

const result = await users.find(
  { age: 25 },
  {
    projection: ["name", "email"],
    limit: 10,
    offset: 0
  }
);

console.log(result);

Highlights

  • Encrypted document storage with AES-256-GCM.
  • Secondary indexes for equality and range-style query routing.
  • collection.count() in O(1) time.
  • find() pagination and projection support.
  • aggregate() pipeline support with $match, $group, $project, $skip, and $limit.
  • Query explain plans through collection.explain() and db.explain(...).
  • WAL-backed transaction recovery.
  • Encryption key rotation for stored documents and WAL files.
  • Multi-node building blocks: Raft leader election (cluster mode), push-based WAL streaming replication, read-replica nodes, and optional per-collection sharding.

Main API

Manager

const manager = new LioranManager({
  rootPath: "./data",
  encryptionKey: "secret",
  ipc: "primary" // optional: "primary" | "client" | "readonly"
});

Cluster (Raft + WAL streaming)

Run multiple nodes with the same cluster.peers list; Raft elects a leader, followers stream WAL in near real-time.

const manager = new LioranManager({
  rootPath: "./data-node-1",
  cluster: {
    enabled: true,
    nodeId: "n1",
    host: "127.0.0.1",
    raftPort: 7101,
    walStreamPort: 7201,
    peers: [
      { id: "n2", host: "127.0.0.1", raftPort: 7102, walStreamPort: 7202 },
      { id: "n3", host: "127.0.0.1", raftPort: 7103, walStreamPort: 7203 }
    ],
    // optional: waitForMajority: true
  }
});

Followers are read-replicas by default; writes are only accepted on the elected leader.

Sharding

const manager = new LioranManager({
  rootPath: "./data",
  ipc: "primary",
  sharding: { shards: 8 } // routes by hash(_id) % N
});

Storage Tuning (Bloom / Compaction / LevelDB options)

const manager = new LioranManager({
  rootPath: "./data",
  ipc: "primary",
  storage: {
    // classic-level uses a Bloom filter internally (10 bits/key by default).
    bloomFilterBits: 10,

    // Adaptive compaction (uses write load + read amplification heuristics).
    adaptiveCompaction: {
      enabled: true,
      writeOpsPerMin: 50_000,
      readAmplificationThreshold: 25
    },

    // Pass-through LevelDB tuning knobs (classic-level).
    leveldb: {
      cacheSize: 256 * 1024 * 1024,
      writeBufferSize: 64 * 1024 * 1024,
      blockSize: 16 * 1024,
      maxOpenFiles: 500,
      compression: true
    }
  }
});

Latency Budgets (<100ms reads/writes)

Budgets are best-effort by default (warn on violations). You can switch to hard timeouts with onViolation: "throw".

const manager = new LioranManager({
  rootPath: "./data",
  ipc: "primary",
  latency: {
    readBudgetMs: 100,
    writeBudgetMs: 100,
    walAppendBudgetMs: 5,
    onViolation: "warn" // "none" | "warn" | "throw"
  },
  // For low-latency writes, prefer async durability (avoids fsync-on-commit).
  durability: { level: "async" }
});

Metrics & Observability

Get production-ready stats (latency p50/p95/p99, cache hit rate, WAL lag, replication delay):

const stats = (await manager.db("app")).stats();
console.log(stats.latencyMs.read, stats.cache.query, stats.replication);

Background Tasks

Enable a central scheduler (primary nodes) for:

  • Auto index rebuild (if index files are missing)
  • Auto compaction (reuses the existing maintenance logic)
  • Cache cleanup (light decay)
const manager = new LioranManager({
  rootPath: "./data",
  ipc: "primary",
  background: { intervalMs: 10_000 }
});

Database

const db = await manager.db("app");

await db.createIndex("users", "email", { unique: true });
await db.compactAll();
await db.rotateEncryptionKey("new-secret");

const explain = await db.explain("users", { email: "[email protected]" });

Collection

const users = db.collection("users");

await users.insertOne({ name: "Ava", age: 25 });
await users.insertMany([{ name: "Ben", age: 30 }]);

const docs = await users.find(
  { age: { $gte: 18 } },
  { projection: ["name"], limit: 20, offset: 0 }
);

const one = await users.findOne(
  { name: "Ava" },
  { projection: ["name", "age"] }
);

const total = await users.count();

const grouped = await users.aggregate([
  { $match: { age: { $gte: 18 } } },
  { $group: { _id: "$age", count: { $sum: 1 } } }
]);

Transactions

await db.transaction(async (tx) => {
  tx.collection("users").insertOne({
    name: "Ava",
    email: "[email protected]"
  });
});

Transactional writes are recorded in the WAL and recovered on restart if needed.

Docs

Notes

  • Document payloads are encrypted at rest.
  • WAL records are encrypted.
  • Index contents are stored separately from documents and are not currently encrypted.
  • Query projection reduces returned payload size and response serialization work, but documents are still stored as encrypted blobs, so matched documents are still fully read and decrypted before projection is applied.

License

LDEP