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

kahon

v0.3.0

Published

TypeScript reader for the Kahon binary JSON format

Downloads

367

Readme

Kahon for JS

A TypeScript/JavaScript reader for the Kahon binary format.

Quick start

npm install kahon
import { BufferSource, FileSource, KahonReader } from "kahon";

await using src = await FileSource.open("./data.kahon");
const r = await KahonReader.fromSource(src);
// JSON Pointer Syntax
await r.get("/users/0/name");
// Iterate children of the root (works for arrays and objects).
for await (const c of await r.root()) {
  await c.get("name");        // descend into an object child
  await c.at(0);              // descend into an array child
  await c.decode();           // materialize this subtree as a plain JS value
}

// In-memory, mostly for testing. BufferSource has no resources to release.
const r2 = await KahonReader.fromSource(new BufferSource(buf));
await r2.get("/users/0/name");

The reader can open files much larger than RAM. It only loads the bytes it needs to answer the lookups you make.

Reader Options

Pass options as the second argument to fromSource:

await KahonReader.fromSource(src, {
  eagerEntriesThreshold: 64 * 1024,
  readChunkBytes:        16 * 1024,
  sourceCacheBytes:       4 * 1024 * 1024,
  validateLeafKeys:      true,
  maxContainerEntries:   Infinity,
});

The defaults are tuned for a balance of speed and memory on mid-sized data. Reach for these knobs when you have a specific bottleneck:

| Option | Description | Lower | Higher | Notes | | --- | --- | --- | --- | --- | | eagerEntriesThreshold | When to load a container's index in one shot vs. stream it | Less RAM per container, slower repeated lookups | Faster lookups, more RAM per container | You hit objects/arrays with millions of children and memory matters more than latency (lower it), or you do many lookups on the same container and want them cached (raise it) | | readChunkBytes | Read size for streaming and caching | Less RAM, more IO calls | Fewer IO calls, more RAM | If reads come from a slow source (network, S3) - raise it. Otherwise, if memory is very tight, lower it. | | sourceCacheBytes | Total budget for cached file chunks | Less RAM, repeat reads hit disk | Fewer disk reads, more RAM | You do many lookups on the same file (raise it). One-shot full scan or memory-constrained (set 0 to disable) | | validateLeafKeys | Verifies object keys are sorted before binary search | (false) Faster first lookup per object, unsafe with untrusted data | (true, default) Safe against malformed input | | | maxContainerEntries | Hard cap on container size | | | |

Custom sources

Implement ByteSource for HTTP range requests, mmap, S3, etc.:

const r = await KahonReader.fromSource(new MyCustomSource(), {
  sourceCacheBytes: 1 * 1024 * 1024,
});

fromSource automatically wraps the source with a chunk cache unless sourceCacheBytes: 0 is set or the source is already wrapped.