Growing with the Web

js-data-structures NPM version

Build Status Code Climate Code coverage

A collection of data structures written in JavaScript. Each data structure is enclosed in its own file, wrapped in a Universal Module Definition (UMD) API to make it easier to use across multiple platforms.

Detailed information on the complexity of each data structure is located here. To learn more about how some of the data structures are implemented, have a look at the technical articles on my blog.

Installing

npm install --save js-data-structures

Including

var FibonacciHeap = require("js-data-structures").FibonacciHeap;

Usage

See the source files for a list of public interfaces on each data structure, here is an example for the Fibonacci heap.

var heap = new FibonacciHeap();
heap.insert(3);
heap.insert(7);
heap.insert(8);
heap.insert(1);
heap.insert(2);

while (!heap.isEmpty()) {
  console.log(heap.extractMinimum());
}

Contributing

I’d love to get some contributions for other data structures, if you want to make a pull request try to follow the existing style of the code and make sure you add tests for the new data structure.

Testing locally

npm install
npm test

# generate coverage report in ./coverage/
grunt coverage

See also