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 🙏

© 2024 – Pkg Stats / Ryan Hefner

cow-list

v2.1.0

Published

Copy-on-write iterable list

Downloads

38

Readme

Cow List 🐄🐄🐄

CI status Coverage percentage NPM version

Cow List provides a Copy-On-Write iterable list that supports logarithmic searches. It provides also a mutable iterable List with versioning capabilities.

Cow List naively supports lengthy values (objects with a length property). This makes Cow List a perfect fit to implement a rope.

Highlights

Immutable or mutable

Cow List provides immutable lists and mutable lists. Immutable lists are well-suited for projects that embrace immutability and purity. They use a copy-on-write strategy to achieve better performances. Mutable lists have versioning capabilities that enable to fork a the list into two independent mutable lists. They are well-suited for projects that implements their own copy-on-write data structures.

A building block

Cow List implements a close to minimum set of features. This makes Cow List lightweight (2kB minified and gziped). These features are carefully chosen for enabling the design of advanced data structures. For instance, Cow List enables to implement sorted lists and ropes.

Lengthy values

Cow List is aware of lengthy values (objects with a length property). When you iterate over a list, you have access to the cumulated length (summary) of the traversed values. This enables to efficiently implement a rope.

Logarithmic searches

The main way to traverse a list is to get an iterator. Cow List enables to logarithmically chooses where to start the iteration.

Getting started

Install cow-list as a dependency:

npm install cow-list

Immutable list

import { CowList } from "cow-list"

let l = CowList.empty<string>()
l = l.inserted(0, "ab")
l = l.inserted(1, "c")
l = l.inserted(2, "d")
l = l.deleted(1)
l = l.replaced(1, "de")

for (const v of l) {
    console.log(v)
    // ab
    // de
}

Mutable list

import { MutList } from "cow-list"

let l = MutList.empty<string>()
l.insert(0, "ab")
l.insert(1, "c")
l.insert(2, "d")
l.delet(1)
l.replac(1, "de")

for (const v of l) {
    console.log(v)
    // ab
    // de
}

Advanced usages

Please take a look to the provided examples.

FAQ

Why did you design yet another list?

I wished to have a generic building block to implement Dotted LogootSplit. Dotted LogootSplit is a new replicated data structure designed for collaborative editing. The data structure combines a search tree and a rope.

Which data structure is internally used?

For now, Cow List uses a partially persistent AVL tree. This could change in the future in order to achieve better performances.