npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

flatten-interval-tree

v0.2.3

Published

Interval Tree implementation as augmented binary red-black tree

Downloads

1,742

Readme

Interval Tree

npm version Build Status

Interval Tree implementation as it is described in Cormen et al. (2009, Section 14.3: Interval trees, pp. 348–354).

Important note

This package is not supported and will be deprecated soon. Consider moving to the scoped version @flatten-js/interval-tree.

Contacts

Follow me on Twitter @alex_bol_

Installation

npm install flatten-interval-tree -save

Usage

let IntervalTree = require('flatten-interval-tree');

API Reference

Constructor

Create new instance of interval tree

let tree = new IntervalTree();

Insert(key, value)

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);

Exist(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);

Remove(key, value)

Removes item from the tree. Returns true if item was actually deleted, false if not found

let removed = tree.remove(key, value);

Search(interval)

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);

Size (getter)

Returns number of items stored in the tree

let size = tree.size;

ForEach(visitor)

Enables to traverse the whole tree and perform operation for each item

tree.forEach( (key, value) => console.log(value) )

Tests

npm test

Contributors

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.

License

MIT