New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

interval-tree2

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

interval-tree2

interval tree in javascript

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
479
increased by19.75%
Maintainers
1
Weekly downloads
 
Created
Source

Circle CI

interval-tree2

interval tree in JavaScript (source is written in CoffeeScript)

improves previous interval-tree

more maintenanceability with CoffeeScript OOP.

more robustness with mocha, CircleCI

API Documentation

latest API documentation Page (YUIDoc)

installation

$ npm install interval-tree2

usage

require


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

when using in web, use dist/interval-tree.js in this module.

<script src="dist/interval-tree.js"></scirpt>

create

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

add interval data

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
itree.add(1, 38); // id is automatically set when not given

search by point: get overlapped intervals from one point

var intervals = itree.search(103);

or

var intervals = itree.pointSearch(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 by range: get overlapped intervals from a range

var intervals2 = itree.search(103, 400);

or

var intervals2 = itree.rangeSearch(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
});

remove an interval by id

itree.remove('foo');

Keywords

FAQs

Package last updated on 23 Sep 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc