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

flxdb-stats

v0.1.2

Published

A lightweight, zero-dependency statistics and metrics wrapper for flxdb. Tracks read/write/delete operations, latency, uptime, file size, and more.

Readme

📊 flxdb-stats

flxdb-stats is a lightweight, fast and zero-configuration
statistics & metrics plugin for the flxdb database in Node.js.

It wraps your flxdb instance using a Proxy, transparently tracking
reads, writes, deletes, latency, uptime, file size and more —
in real time, without touching the original API.


📦 Installation

npm install flxdb flxdb-stats

🚀 Quick Usage

const db = require("flxdb");
const { withStats } = require("flxdb-stats");

const statsDb = withStats(db, {
  filePath: "./flxdb/flxdb.json"
});

statsDb.set("user.name", "Lewira");
statsDb.add("system.uptime", 1);
statsDb.get("user.name");
statsDb.delete("user.session");

console.log(statsDb.getStats());

ℹ️ All flxdb methods continue to work exactly the same.
flxdb-stats only observes and collects statistics.


🔧 Features

  • 📊 Read / write / delete counters
  • 🕒 Uptime & last operation tracking
  • 📁 JSON file size measurement
  • 🔍 Per-method call statistics
  • ⚡ Latency measurement (avg / max / total / per-method)
  • 🔌 Proxy-based (no API overrides)
  • ⚙️ Zero configuration
  • 🚀 Ultra-lightweight & fast
  • 🟦 Full TypeScript support

🧩 API

withStats(db, options?)

Wraps a flxdb instance and starts collecting statistics.

| Parameter | Type | Description | |--------|------|------------| | db | object | flxdb instance (require("flxdb")) | | options.filePath | string? | Path to flxdb JSON file (optional) | | options.trackLatency | boolean? | Enable latency tracking (default: true) | | options.ignoreMethods | string[]? | Methods to ignore | | options.label | string? | Custom instance label |


getStats()

{
  label: string | null,

  startedAt: Date,
  lastOpAt: Date | null,

  totalOps: number,

  reads: number,
  writes: number,
  deletes: number,
  other: number,

  calls: Record<string, number>,
  timings: Record<string, MethodTiming>,
  latency: {
    totalMs: number,
    maxMs: number,
    avgMs: number
  },

  lastOperation: {
    method: string | null,
    kind: "read" | "write" | "delete" | "other" | null,
    at: Date | null,
    durationMs: number | null
  },

  uptimeMs: number,
  uptimeSeconds: number,
  fileSizeBytes: number | null
}

🧠 How It Works

  • flxdb instance is wrapped inside a Proxy
  • Every method call is intercepted automatically
  • Operations are classified (read / write / delete / other)
  • Execution time and timestamps are recorded
  • Original return values are preserved

✔ 100% compatibility
✔ Minimal overhead
✔ Safe and transparent usage


🧪 Example: Live Monitoring

setInterval(() => {
  console.clear();
  console.table(statsDb.getStats());
}, 2000);

🔑 Symbol Access

Stats can also be accessed via a global symbol:

const { STATS_SYMBOL } = require("flxdb-stats");

const stats = statsDb[STATS_SYMBOL]();

🔄 JSON-safe Serialization

const { statsToJSON } = require("flxdb-stats");

const json = statsToJSON(statsDb.getStats());
console.log(JSON.stringify(json, null, 2));

🧩 TypeScript Support

Full IntelliSense is provided via index.d.ts:

import { withStats, FlxdbStats, FlxdbStatsJSON } from "flxdb-stats";

const stats: FlxdbStats = statsDb.getStats();
const json: FlxdbStatsJSON = statsToJSON(stats);

🛠 Suitable For

  • CLI tools
  • Local JSON cache systems
  • Monitoring & debug tools
  • Discord / Telegram bots
  • Small & medium Node.js projects

📄 Changelog — v0.1.2

🚀 Stable Release Improvements

  • Full Proxy-based tracking
  • Improved read/write/delete classification
  • Per-method call counters
  • Latency tracking (global & per-method)
  • Enhanced last operation snapshot
  • Uptime and file size tracking
  • JSON-safe serialization (statsToJSON)
  • Complete TypeScript definitions
  • Symbol-based stats access
  • README improved and merged
  • Version updated to v0.1.2

📄 License

MIT License


⭐ Support

If you like this project, don’t forget to leave a ⭐
Issues, suggestions and contributions are always welcome.