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

@shapeshift-labs/frontier-codec

v0.1.4

Published

Patch serialization, binary frames, and history codecs for Frontier patches.

Readme

Frontier Codec

Patch serialization, binary frames, and patch-history codecs for Frontier.

This package sits above @shapeshift-labs/frontier, the small JSON diff/apply core package. It keeps transport, persistence, and canonicalization helpers in a separate package so core imports stay small and predictable.

Related Packages

Package source repositories:

Install

npm install @shapeshift-labs/frontier @shapeshift-labs/frontier-codec

Usage

import { diff, applyPatchImmutable } from '@shapeshift-labs/frontier';
import { encodePatch, decodePatch } from '@shapeshift-labs/frontier-codec';

const before = { count: 1 };
const after = { count: 2 };

const patch = diff(before, after);
const bytes = encodePatch(patch);
const decoded = decodePatch(bytes);

console.log(applyPatchImmutable(before, decoded));

API

import {
  serializePatch,
  deserializePatch,
  encodePatch,
  decodePatch,
  encodePatchBase64url,
  decodePatchBase64url,
  encodePatchHistory,
  decodePatchHistory,
  applyPatchHistory,
  applyEncodedPatchHistory,
  createPatchHistoryBuilder,
  createCodecSchemaId,
  encodePatchFrame,
  decodePatchFrame,
  encodePatchHistoryFrame,
  decodePatchHistoryFrame,
  inspectCodecFrame,
  readCodecFramePayload,
  stringifyCanonicalJson,
  encodeCanonicalJson
} from '@shapeshift-labs/frontier-codec';

What It Provides

Frontier Codec is for moving Frontier patches across process, network, and storage boundaries:

  • serializePatch() / deserializePatch() for compact JSON-safe patch payloads.
  • encodePatch() / decodePatch() for binary patch payloads.
  • encodePatchBase64url() / decodePatchBase64url() for URL/header-safe transport strings.
  • encodePatchHistory() / decodePatchHistory() for compact patch-history persistence.
  • applyPatchHistory() / applyEncodedPatchHistory() for replaying stored histories.
  • createPatchHistoryBuilder() for incremental history assembly.
  • encodePatchFrame() / decodePatchFrame() for versioned typed wire frames.
  • inspectCodecFrame() / readCodecFramePayload() for metadata-first frame handling.
  • stringifyCanonicalJson() / encodeCanonicalJson() for deterministic signing, hashing, and cache keys.

Binary Patch Transport

import { diff, applyPatchImmutable } from '@shapeshift-labs/frontier';
import { encodePatchBase64url, decodePatchBase64url } from '@shapeshift-labs/frontier-codec';

const patch = diff({ title: 'Draft' }, { title: 'Published' });
const token = encodePatchBase64url(patch);

const received = decodePatchBase64url(token);
const next = applyPatchImmutable({ title: 'Draft' }, received);

Patch History

import { applyEncodedPatchHistory, encodePatchHistory } from '@shapeshift-labs/frontier-codec';

const encoded = encodePatchHistory([
  [{ op: 'add', path: ['items'], value: [] }],
  [{ op: 'add', path: ['items', 0], value: { id: 'a', done: false } }]
]);

const current = applyEncodedPatchHistory({}, encoded);

Versioned Frames

import { encodePatchFrame, inspectCodecFrame, readCodecFramePayload } from '@shapeshift-labs/frontier-codec';

const frame = encodePatchFrame([{ op: 'replace', path: ['count'], value: 2 }], {
  schemaId: 'counter-v1'
});

const info = inspectCodecFrame(frame);
const bytes = readCodecFramePayload(frame);

Canonical JSON

import { stringifyCanonicalJson } from '@shapeshift-labs/frontier-codec/canonical';

const stable = stringifyCanonicalJson({ b: 2, a: 1 });
// {"a":1,"b":2}

Subpath Imports

import { encodePatch } from '@shapeshift-labs/frontier-codec/codec';
import { encodePatchHistory } from '@shapeshift-labs/frontier-codec/history';
import { encodePatchFrame } from '@shapeshift-labs/frontier-codec/frame';
import { stringifyCanonicalJson } from '@shapeshift-labs/frontier-codec/canonical';
import type { PatchHistoryCodecOptions } from '@shapeshift-labs/frontier-codec/types';

Package Scope

This package is intentionally limited to:

  • Frontier patch string and binary codecs.
  • Base64url patch transport helpers.
  • Patch-history encoding and replay.
  • Versioned codec frames.
  • Canonical JSON helpers for transport, hashing, and signing workflows.

CRDT update codecs live in the CRDT package layer. State routing, sync providers, awareness, rich text, and document handles are separate layers.

TypeScript

The package ships ESM JavaScript plus .d.ts declarations for every public subpath. The package-local TypeScript source lives in src/ and compiles directly to dist/; it is not copied from the monorepo root build output.

Validation

The package test suite covers:

  • smoke imports for every public subpath;
  • type-checking examples against the published declarations;
  • deterministic patch/history/frame/canonical conformance cases;
  • index-list binary codec fuzzing;
  • patch/history/frame round-trip fuzzing against @shapeshift-labs/frontier diff/apply.

Run it with:

npm test

Run the package-local fuzzer directly:

npm run fuzz

For a publish dry run:

npm run pack:dry

Benchmarks

Run the package-local benchmark:

npm run bench

Latest local package benchmark on Node v26.1.0, darwin arm64, 3 rounds:

| Fixture | Median | p95 | | --- | ---: | ---: | | Patch encode, 1k keyed-row edit, 30 B | 0.61 us | 0.66 us | | Patch decode, 1k keyed-row edit, 30 B | 0.36 us | 0.43 us | | Frame inspect + payload slice, 70 B | 0.40 us | 0.42 us | | Frame decode, 1k keyed-row edit, 70 B | 0.59 us | 0.62 us | | History decode+apply, 128 patches, 2.8 KiB | 56.11 us | 56.47 us | | Canonical JSON stringify, 523 B | 6.34 us | 6.49 us |

These are Frontier-only package measurements, not competitor comparisons.

License

MIT. See LICENSE.