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

@browndragon/collections

v0.0.13

Published

Collection datastructures in the style of es6: Multimaps, SortedSets and SortedMaps, as well as the row & column-indexed Table.

Downloads

15

Readme

@browndragon/collections

A collection of es6-like datastructures I wanted to use and didn't find an equivalent quickly enough in npm.

EmptyIter

A quick iteratable & iterator that contains nothing. I'm not sure if you usually return function*(){}() but since I wanted to cache the entry anyway...

MultiMap

A Map<K, Set<V>> (... more or less...).

From an insertion point of view, you add(k,v) (instead of set(k,v)), and multiple adds don't result in overwriting the value of k. map.get(k) returns an iterator of values. Iterators conceive of the entries as pairs [k, v] for nonunique k.

SortedMap and SortedSet

These types assume "phased" interactions -- a flurry of modifications followed by a flurry of reads or iterations, followed by a flurry of modifications etc. As a result, they cache an iteration order (via sorted array) calculated whenever an iteration follows a dirtying operation.

Anyway; they change the es6 guaranteed sorting order from "insertion order" to "natural sorting order". You can modify this with FooClass.comparing((a, b)=> 0 /* or -1 or +1, as appropriate */) -- which returns a new subclass.

Ranges

The iteration methods (entries, keys, values, etc) generally accept optional parameters begin and end (so: someMap.entries(begin, end)). Undefined limits nothing; the first iterated element will be equal to or greater than begin, the last iterated element will be strictly less than end.

Table

A 2-d Map; you can think of it a little bit as a Map<[Krow, Kcol], V>.

From an insertion point of view, you set(row, col, val). From an iteration point of view, you iterate over [[row, col], val] -- and the constructor's iterator argument expects the values to be bunched in this fashion.

Additional methods are provided to use the row-based (or without loss of generality, column-based) view of the data as restricted by some of the keys.

The Table itself has a native iteration order (as Map, the order of entries created). However, using various index restrictions, you will get the iteration order of the index type -- rows can be thought of as a map of columns->values, and columns a map of rows->values; the constructor accepts an additional 2 parameters to use other map implementations (SortedMap, for instance).

Usage

import collections from '@browndragon/collections';

// TODO: DEMONSTRATE API