Socket
Socket
Sign inDemoInstall

treemap-js

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    treemap-js

A binary tree based map (aka dictionary) data type for Javascript, keeping keys sorted at all times


Version published
Weekly downloads
1.2K
increased by71.13%
Maintainers
1
Install size
9.14 kB
Created
Weekly downloads
 

Readme

Source

TreeMap.js

A binary tree based map (aka dictionary) data type for Javascript, keeping keys sorted at all times. Provides O(log n) average case performance for inserting, retrieving and removing values.

Installation

Works with Node and in the browser.

Node

Install via npm install treemap-js. Then access the TreeMap like this:

const TreeMap = require("treemap-js");

Browser

Include TreeMap.js in your HTML. TreeMap is automatically appended to the window object.

Usage

var map = new TreeMap();

map.set("my first key", "hello");    // keys can be strings, numbers or booleans. Values can be any data type
map.set("second key", [ 1, 3, 4 ]);
map.get("my first key");    // returns "hello"

map.set("my first key", 2342);
map.get("my first key");    // returns 2342

map.getLength();    //  returns 2

map.getMinKey();    // returns "my first key"
map.getMaxKey();    // returns "second key"

map.each(function (value, key) {
    // do something...
});

map.remove("my first key");
map.getLength();    // returns 1

map.getTree();    // returns the backing tree object

Keywords

FAQs

Last updated on 13 Mar 2018

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc