
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
flatten-interval-tree
Advanced tools
Interval Tree implementation as augmented binary red-black tree
Interval Tree implementation as it is described in Cormen et al. (2009, Section 14.3: Interval trees, pp. 348–354).
Follow me on Twitter @alex_bol_
npm install flatten-interval-tree -save
let IntervalTree = require('flatten-interval-tree');
Create new instance of interval tree
let tree = new IntervalTree();
Insert new item into the tree. Key is and interval object or an array of [low, high] numeric values.
Value may represent any value or refer to any object. If value omitted, tree will store and retrieve keys only.
If key is an object, it should expose low and high properties and implement the following methods:
less_than, equal_to, intersect, clone, output, maximal_val, val_less_than.
Method returns reference to the inserted node
let node = tree.insert(key, value);
Method returns true if entry {key, value} exists in the tree.
Method may be useful if need to support unique items.
let exist = tree.exist(key,value);
Removes item from the tree. Returns true if item was actually deleted, false if not found
let removed = tree.remove(key, value);
Returns array of values which keys intersected with given interval.
If tree stores only keys with no values, search returns array of keys which intersect given interval
let resp = tree.search(interval);
Returns number of items stored in the tree
let size = tree.size;
Enables to traverse the whole tree and perform operation for each item
tree.forEach( (key, value) => console.log(value) )
npm test
In lieu of a formal style guide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.
MIT
FAQs
Interval Tree implementation as augmented binary red-black tree
The npm package flatten-interval-tree receives a total of 332 weekly downloads. As such, flatten-interval-tree popularity was classified as not popular.
We found that flatten-interval-tree demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.