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

json-mach

v1.2.2

Published

Makes JSON a hell of a lot faster.

Readme

JSON Mach

Revolutionaly technology which makes JSON up to 350 times faster (in lookups).

May or may not be powered by lmdb

Installation

Install using npm:

npm install json-mach

(Note: Requires Node.js >= 22.5.0)


Example Use

import { open } from 'json-mach';

// Opens and wraps the data structure
const data = open('data.json');

// Read values like normal JavaScript objects/arrays
console.log(data.title);         // "demo"
console.log(data.nested.y.z);    // 2

Example Queries

Assume the underlying data.json contains:

{
  "title": "demo",
  "nested": { "x": 1, "y": { "z": 2 } },
  "users": [
    { "id": 1, "name": "Alice", "age": 30, "vip": true },
    { "id": 2, "name": "Bob", "age": 25, "vip": false },
    { "id": 3, "name": "Carol", "age": 40, "vip": true }
  ]
}

Object Properties & Nesting

Access nested keys directly. The proxy traverses the LMDB B-tree on demand:

console.log(data.nested.y.z); // 2

Index Lookups on Flat Arrays

For arrays of objects, json-mach enables index-optimized lookups:

  • Point lookups by ID:
    const bob = data.users.findById(2);
    // => { id: 2, name: 'Bob', age: 25, vip: false }
  • Equality filter:
    const vips = data.users.where('vip', true);
    // => [ { id: 1, name: 'Alice', ... }, { id: 3, name: 'Carol', ... } ]

Array Iteration & Methods

You can iterate or run standard functional array methods on the proxy arrays:

// Array length
console.log(data.users.length); // 3

// Index access
console.log(data.users[0].name); // "Alice"

// Spread & Map
const names = [...data.users].map(u => u.name); // ['Alice', 'Bob', 'Carol']

// Built-in Array Helper proxies
const youngerThan30 = data.users.filter(u => u.age < 30);
const carol = data.users.find(u => u.name === 'Carol');

Writing & Modifying Data

Any changes made to the proxy are synchronized to the LMDB cache in real-time.

// Add or update object keys
data.nested.x = 99;
data.newKey = 'added';

// Delete object keys
delete data.title;

// Update flat-array elements by their 'id'
data.users.updateById(2, { name: 'Bobby', age: 26 });

// Delete flat-array elements by their 'id' (updates array length)
data.users.deleteById(3); 

Batch Transactions

When performing multiple updates or deletes in a loop, wrap them in a transaction to avoid the overhead of multiple disk flushes and compile-to-disk times.

import { openWithStats, transaction } from 'json-mach';

const { data, db } = openWithStats('data.json');

transaction(db, () => {
  for (let id = 1; id <= 1000; id++) {
    data.users.updateById(id, { score: 100 });
  }
});

Options

open and openWithStats accept an options object:

const { data } = openWithStats('data.json', {
  // Path where the cache database is stored. Defaults to "${jsonPath}.jsonm"
  cachePath: 'path/to/custom.jsonm',

  // Specify which fields to build secondary indexes for on flat arrays.
  // Defaults to ['id']
  indexFields: ['id', 'vip'],

  // Opens the LMDB environment in read-only mode, bypassing the write-lock.
  // Set to true to maximize read performance.
  readOnly: false
});

Materializing to Plain JSON

To convert the proxy back to a normal, un-proxied JavaScript object (e.g., for serialization), run JSON.stringify or call the materialize utility:

import { openWithStats, materialize } from 'json-mach';

const { data, db } = openWithStats('data.json');

// Option A: JSON serialization
const plainObj = JSON.parse(JSON.stringify(data));

// Option B: Selective materialization
const materializedUser = materialize(db, ['users', 0]);