[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

This package provides JavaScript implementations of common collections, with many useful features.

These collections provide specialized alternatives to plain arrays and objects. They include the ability to observe all changes, have a common interface across every collection and work in both Node.js and the browser.

Some data structures are better suited for specific problems. The collections package gives you the freedom to experiment with different approaches, without having to change your existing usage.

Each collection implements generic methods, many already familiar from ordinary Arrays, and many new methods that will enrich your toolset.

Add to your project with npm:

npm install --save collections

and use by requiring each collection as needed:

var LruMap = require("collections/lru-map");

Works in Node.js, Browserify and Mr.

Choose a collection

What kind of collection are you looking for?



What will the keys be?





Can you sacrifice iterability to gain better garbage collection?

Do you need the collection to prevent duplicate values?

Will you ever need to visit every value in the collection in order?

Do you need the collection to keep the values in sorted order?

Do you need to limit the size of the collection and automatically evict stale values?

Is it better to forget a value if it wasn't used recently, or if thasn't been used frequently?


Would it be convenient if the values were always a particular collection, like a map from keys to sets?

Will this collection get big, bigger than around 1000 values?

Where will you need to access values quickly?

Where will you need to make changes quickly?

Is it better to waste time on garbage collection or shifting values around?