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 🙏

© 2025 – Pkg Stats / Ryan Hefner

delta-crdts-esm

v1.0.0

Published

Updated Delta-based State CRDTs by Pedro Teixeira

Readme

delta-crdts-esm

This is a fork

An ESM/Typescript port of delta-crdts, just to make it a bit easier to work with, and with some updates to newer dependencies. See the original page for the docs and a video demonstration.

A tremendous thank you to the original author for the comprehensive test suite, updates would have been impossible without it.

npm install delta-crdts-esm
import CRDT from 'delta-crdts-esm'
const RGA = CRDT('rga');
const rga = RGA('identifier')
etc...

Note these omissions in the original documentation:

  • lwwreg.write() takes two parameters, timestamp and value.
  • rwlwwset.add() and rwlwwset.remove() also take timestamp, value.

Timestamps can be anything comparable with < and > but you probably want to use something like an HLC.

Note also that joining states or deltas requires a CRDT instance (e.g. MVREG('random').join()), and not the CRDT factory as indicated in the original documentation.

The CRDT type ('gcounter', 'rga', etc.) is also now accessible with [mycrdtinstance].type, and on deltas with [mydeltainstance].__crdt.type.

Encoding and decoding

Also moved the MessagePack codec here so an additional dependency is not necessary. It will encode/decode plain deltas, CRDT state, and more complex objects containing CRDT state/deltas.

import { encode, decode } from 'delta-crdts-esm'

const someObject = {
  nil: null,
  integer: 1,
  float: Math.PI,
  string: "Hello, world!",
  binary: Uint8Array.from([1, 2, 3]),
  array: [10, 20, 30],
  map: { foo: "bar" },
  delta: someCRDTDelta, 
  timestampExt: new Date(),
};

const encoded = encode(object); 
const decoded = decode(encoded);

This works fine for transmitting over the wire, but if you're saving to a database, you probably only want to encode/decode the deltas or CRDTs themselves and not the associated metadata.

Types

With types:

import CRDT, { type RGAFactory } from "delta-crdts-esm";

const RGA = CRDT("rga") as RGAFactory<string>;
const rga = RGA("list");

rga.push("hello");
rga.push("world");

const list = rga.value();

And we also have instance types:

import type { MVRegInstance } from "delta-crdts-esm";

let mvreg: MVRegInstance<string>;

Dev

Run the test Typescript file as follows:

node --loader ts-node/esm test/typed.ts

Acknowledgements

ChatGPT ^5.0 did most of the work here...