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

reptree

v1.0.2

Published

A tree data structure using CRDTs for seamless replication between peers

Readme

RepTree

RepTree is a small TypeScript library for replicated trees with properties.

Use it when your application state is naturally a tree and multiple peers may edit it: folders, documents with nested blocks, scene graphs, project structures, object graphs, or any UI model where nodes can move and carry properties.

RepTree is built on CRDTs, so peers can exchange operations in any order and converge on the same state without a central merge coordinator.

Install

npm install reptree

What RepTree Gives You

  • Tree nodes that can be created, moved, deleted, and observed.
  • JSON-serializable properties on every node.
  • Last-writer-wins property conflict resolution.
  • Move conflict resolution based on the move operation tree CRDT.
  • Operation-based sync for persistence or peer replication.
  • State vectors for efficient delta sync.
  • Optional typed/reactive node bindings.

Basic Usage

import { RepTree } from "reptree";

const tree = new RepTree("peer-a");
const root = tree.createRoot();
root.name = "Project";

const docs = root.newNamedChild("Docs", {
  type: "folder",
  icon: "folder",
});

const readme = docs.newNamedChild("README.md", {
  type: "file",
  size: 2048,
  tags: ["docs", "intro"],
});

const assets = root.newNamedChild("Assets", { type: "folder" });
readme.moveTo(assets);

console.log(readme.parent?.name); // "Assets"
console.log(readme.getProperty("size")); // 2048

Sync

RepTree syncs by exchanging operations. Store operations, send them over the network, and merge operations received from other peers.

import { RepTree } from "reptree";

const alice = new RepTree("alice");
const aliceRoot = alice.createRoot();
aliceRoot.newNamedChild("Roadmap", { status: "draft" });

const bob = new RepTree("bob");
bob.merge(alice.getAllOps());

bob.root!.newNamedChild("Notes", { status: "open" });
alice.merge(bob.getAllOps());

For larger trees, use state vectors to send only operations the other peer is missing:

const aliceVectors = alice.getStateVectors();

if (aliceVectors) {
  const opsForAlice = bob.getMissingOps(aliceVectors);
  alice.merge(opsForAlice);
}

Property operations are compacted by (nodeId, key): RepTree keeps the latest winning property operation for each property and uses the property state vector to describe that retained, sendable set. Move operations keep their history so the move CRDT can resolve structural conflicts.

Typed Nodes

You can bind a node to a live typed object. Reads and writes go through RepTree.

type Task = {
  title: string;
  done: boolean;
};

const task = root.newNamedChild("Task").bind<Task>();
task.title = "Write README";
task.done = false;

task.$observe(() => {
  console.log(task.title, task.done);
});

Zod-style schemas are supported for runtime validation:

import { z } from "zod";

const TaskSchema = z.object({
  title: z.string(),
  done: z.boolean(),
});

const checkedTask = root.newNamedChild("Checked task").bind(TaskSchema);
checkedTask.title = "Publish package";
checkedTask.done = true;

Operation Model

RepTree uses two conflict-free replicated data types:

  • A move tree CRDT for the tree structure, based on Kleppmann's move operation paper.
  • A last-writer-wins (LWW) CRDT for node properties.

Both streams have independent counters and state vectors. This keeps property-heavy workloads compact while preserving the move history needed for deterministic tree convergence.

Origin

RepTree was created for Sila, an open-source alternative to ChatGPT.

License

MIT