JSPM

interval-tree2

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 144
  • Score
    100M100P100Q88123F
  • License MIT

interval tree in javascript

Package Exports

  • interval-tree2

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (interval-tree2) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Circle CI

interval-tree2

interval tree in JavaScript (source is written in CoffeeScript)

API Documentation

latest API documentation Page (YUIDoc)

installation

$ npm install interval-tree2

usage

// add interval data

var itree = new IntervalTree(300); // 300 : the center of the tree

itree.add(22, 56,  'foo'); // 'foo' is the id of the interval data
itree.add(44, 199, 'bar'); // 'bar' is the id of the interval data

// search 1: get overlapped intervals from one point (See Interval class)
var intervals = itree.search(103);

intervals.forEach(function(interval) {
  console.log(interval.start); // overlapped interval start position
  console.log(interval.end);   // overlapped interval end position
  console.log(interval.id);    // id of the overlapped interval
});
// search 2: get overlapped regions from a range
var intervals2 = itree.search(103, 400);

intervals2.forEach(function(interval) {
  console.log(interval.start); // overlapped interval start position
  console.log(interval.end);   // overlapped interval end position
  console.log(interval.id);    // id of the overlapped interval
});