You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

interval-tree

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

interval-tree

interval tree in javascript

0.1.0
latest
npmnpm
Version published
Weekly downloads
112
13.13%
Maintainers
1
Weekly downloads
 
Created
Source

interval-tree

interval tree in JavaScript

Installation

git clone git://github.com/shinout/interval-tree.git

OR

npm install interval-tree

Usage

var IntervalTree = require('interval-tree');

// add interval data

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

itree.add([22, 56,  'foo']);
itree.add([44, 199, 'bar']);

// search 1: get overlapped regions from one point
var results = itree.search(103);

results.forEach(function(result) {
  console.log(result.data); // overlapped range data
  console.log(result.id);   // id of the overlapped range
});

// search 2: get overlapped regions from a range
var results2 = itree.search(103, 400);

results2.forEach(function(result) {
  console.log(result.data);  // overlapped range data
  console.log(result.id);    // id of the overlapped range
  console.log(result.rate1); // overlapped rate to the given range
  console.log(result.rate2); // overlapped rate to the range of this result
});

Keywords

tree

FAQs

Package last updated on 03 Mar 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts