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

@kduma-oss/pcf

v0.0.9

Published

TypeScript implementation of the Partitioned Container Format (PCF) v1.0

Readme

pcf — Partitioned Container Format (TypeScript implementation)

A TypeScript reader/writer for PCF v1.0, a language-agnostic binary container that stores multiple independent byte regions ("partitions") in one file.

This package is a faithful port of the Rust reference implementation (reference/PCF-v1.0/) and mirrors the written specification (specs/PCF-spec-v1.0.txt) field-for-field. It favours auditability over performance and produces the byte-exact canonical test vector from spec section 15.

Layout

[ 20-byte header ] [ table block(s) ] [ partition data regions ]
  • Header (20 B): magic 0x89 K P R T 0x0D 0x0A 0x1A, major/minor version, absolute offset of the first table block.
  • Table block: 74-byte header (partitionCount, nextTableOffset, hash algo + 64-byte block hash) followed by partitionCount entries. Blocks form a singly linked chain to hold more than 255 partitions.
  • Entry (141 B): type, 16-byte UID, 32-byte ASCII label, startOffset, maxLength, usedBytes, 1-byte data-hash algorithm, 64-byte data hash.

All integers are little-endian. u64 fields are modelled as bigint to preserve full 64-bit fidelity; free space is maxLength - usedBytes.

Hash registry

| id | algorithm | id | algorithm | |----|------------------|----|-----------| | 0 | none | 5 | SHA-1 | | 1 | CRC-32/ISO-HDLC | 16 | SHA-256 (default) | | 2 | CRC-32C | 17 | SHA-512 | | 3 | CRC-64/XZ | 18 | BLAKE3 | | 4 | MD5 | | |

Digests are provided by the audited @noble/hashes package; the three CRC variants are implemented in pure TypeScript (src/crc.ts).

Usage

import { Container, HashAlgo } from "pcf";

const c = Container.create();
const uid = new Uint8Array(16).fill(1);
c.addPartition(
  0x10,
  uid,
  "notes",
  new TextEncoder().encode("hello world"),
  64,
  HashAlgo.Sha256,
);

c.verify();
const entries = c.entries();
const data = c.readPartitionData(entries[0]);
console.log(new TextDecoder().decode(data)); // "hello world"

A Container is backed by any Storage. Two implementations ship with the package:

  • MemoryStorage — an in-memory growable buffer (the default for Container.create()).
  • NodeFileStorage — backed by a Node file descriptor:
import { Container, NodeFileStorage, HashAlgo } from "pcf";

const store = NodeFileStorage.open("container.pcf", /* truncate */ true);
const c = Container.create(store);
// … add partitions …
store.close();

Project layout

implementations/ts/pcf/
├── package.json
├── tsconfig.json
├── vitest.config.ts
├── src/                       # library sources
│   ├── consts.ts  errors.ts  crc.ts  hash.ts
│   ├── header.ts  entry.ts   table.ts
│   ├── storage.ts node-storage.ts container.ts
│   └── index.ts               # public re-exports
├── test/
│   ├── roundtrip.test.ts      # end-to-end black-box tests
│   ├── coverage.test.ts       # targeted error-path / edge-case tests
│   └── spec-compliance.test.ts  # one test per normative MUST/SHALL
└── examples/
    └── gen-testvector.ts      # produces the canonical 395-byte spec vector

Scripts

Run from this directory:

npm install            # install dependencies
npm run build          # type-check and emit dist/ (tsc, strict)
npm test               # run the full vitest suite
npm run coverage       # vitest + v8 coverage (95% line / 100% function floor)
npm run gen-testvector # writes pcf_testvector.bin (the 395-byte spec vector)

CI (.github/workflows/ts-ci.yml) runs the type-check/build, the test suite on Linux/macOS/Windows, regenerates and size-checks the spec test vector, and enforces the coverage floor.