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

killer-trees

v0.2.0

Published

Immutable collections based on weight-balanced trees.

Downloads

18

Readme

killer-trees

A collection of immutable data structures, providing a thin wrapper around the weight-balanced-tree package. These offer a more JavaScript-y, class-based API.

Gets/sets/deletes are O(log n) for List, Map, and Set.

List

import List from 'killer-trees/List';

let l = new List([1, 2, 3]);
l.at(1); // 2
l = l.push(4, 5);

Insertions and deletions at any index are also O(log n); no re-indexing needed!

List API.

Map

Map keys can be of any type.

// Import as `KtMap` to avoid conflicting with the `Map` built-in if needed.
import KtMap from 'killer-trees/Map';

let m = new KtMap([['a', 1], [{}, 2], [Symbol(), 3]]);
m.get('a'); // 1
m = m.set('a', 2);

Map API.

Record

Records have a fixed set of properties, defined with Record.define. They're stored more efficiently than maps and type-checked against a specific object type.

Records are currently implemented by storing values as an array, rather than a tree internally. That means gets are O(1), and sets/deletes are O(n), where n is the number of values in the record. Copying an array for small values of n is extremely fast and exhibits less GC pressure than updating a persistent tree.

import Record from 'killer-trees/Record';

type IPoint = {
  x: number,
  y: number,
};

const Point = Record.define<IPoint>({x: 0, y: 0});
let p = new Point({x: 10});
p.get('x'); // 10
p = p.set('x', 20);

Record API.

Set

Unlike the JavaScript Set built-in or Immutable.Set, killer-trees/Set stores values in a defined order. The order is determined by the compareValues static method, which can be overridden by subclassing Set. Sets can store values of any type.

// Import as `KtSet` to avoid conflicting with the `Set` built-in if needed.
import KtSet from 'killer-trees/Set';

new KtSet([1, {}, Symbol()]);

Note: killer-trees/Set's default compareValues method will sort most primitives (other than symbols) in a consistent order across realms and execution environments. Objects and symbols, however, will only be sorted consistently within the current realm and execution environment, and the order is not meaningful.

Set API.

Comparison with Immutable.js

Technical differences

  • killer-trees is based on weight-balanced trees. Immutable.js is based on hash array mapped tries. These have different performance trade-offs. For example, HAMTs have better lookup performance, but trees perform better at concatenation, splicing, and order-preserving set operations. See the results under benchmark/.
  • killer-trees's Set is explicitly ordered, and the value comparison logic can be customized by subclassing and overriding the compareValues method.

Superficial differences

  • While TypeScript definitions are also provided and maintained, Flow support is prioritized here.
  • killer-trees provides a class-based API (new List()), whereas Immutable.js uses factory functions (Immutable.List()).
  • killer-trees is a lightweight wrapper around weight-balanced-tree. Immutable.js is a larger and more feature-rich library.

License

MIT