Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jstreemap

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jstreemap - npm Package Compare versions

Comparing version 1.10.1 to 1.11.1

browser_test/index.html

6

config/webpack.config.js
const path = require('path');
module.exports = {
entry: ['src/red-black-tree.js'],
entry: ['./src/public/main.js'],
output: {
filename: 'setmap.js',
path: path.resolve(__dirname, '../lib'),
filename: 'jstreemap.js',
path: path.resolve(__dirname, '../'),
libraryTarget: 'umd'
}
};
{
"coverage": "100%",
"expectCount": 263,
"actualCount": 263,
"expectCount": 269,
"actualCount": 269,
"files": {

@@ -36,2 +36,7 @@ "src/internal/policies.js": {

},
"src/public/main.js": {
"expectCount": 6,
"actualCount": 6,
"undocumentLines": []
},
"src/public/tree-map.js": {

@@ -38,0 +43,0 @@ "expectCount": 32,

@@ -501,2 +501,8 @@ window.esdocSearchIndex = [

[
"src/public/main.js",
"file/src/public/main.js.html",
"src/public/main.js",
"file"
],
[
"src/public/tree-map.js",

@@ -503,0 +509,0 @@ "file/src/public/tree-map.js.html",

{
"name": "jstreemap",
"version": "1.10.1",
"version": "1.11.1",
"description": "Library of associative containers.",

@@ -11,5 +11,6 @@ "main": "jstreemap.js",

"eslint-fix": "eslint --config=./config/eslint.config.json --fix src/**/*.js test/**/*.js",
"eslint-watch": "esw --config=./config/eslint.config.json -w --fix src/**/*.js test/**/*.js ./*.js",
"eslint-watch": "esw --config=./config/eslint.config.json -w --fix src/**/*.js test/**/*.js",
"test-watch": "mocha --reporter spec -w --recursive test",
"test": "nyc --reporter=html --reporter=text --report-dir=./build/coverage mocha --reporter spec test/**/*.js"
"test": "nyc --reporter=html --reporter=text --report-dir=./build/coverage mocha --reporter spec test/**/*.js",
"postbuild-test": "nyc --reporter=html --reporter=text --report-dir=./build/postbuild-coverage mocha --reporter spec postbuild-test/**/*.js"
},

@@ -16,0 +17,0 @@ "directories": {

# jstreemap
A JavaScript (ES6) library of tree-based associative containers.
A JavaScript (ES6) library of tree-based associative containers. Library is UMD packaged and can be used in a Node environment as well as in a browser. The following containers are provided:
* [**TreeSet**](https://kirusi.github.io/jstreemap/class/src/public/tree-set.js~TreeSet.html) - is a container that stores unique elements following a specific order. In a TreeSet, the value of an element also identifies it (the value is itself the key),and each value must be unique. The value of the elements in a TreeSet cannot be modified once in the container (the elements are immutable), but they can be inserted or removed from the container.

@@ -13,4 +13,36 @@ * [**TreeMap**](https://kirusi.github.io/jstreemap/class/src/public/tree-map.js~TreeMap.html) - is an associative container that stores elements formed

All container implementations are using red-black trees. Detailed library documentation is [here.](https://kirusi.github.io/jstreemap)
All container implementations are using red-black trees.
The library supports ES6 iteration protocol and STL-like iteration. In ES6 one can use a simple for-of loop to iterate through all items.
```js
// forward iteration
for(let [k,v] of map) {
console.log(`key: ${k}, value: ${v}`);
}
// reverse iteration
for(let [k,v] of map.backward) {
console.log(`key: ${k}, value: ${v}`);
}
```
With STL-like explicit iterators one can navigate through specific ranges in the container and update or erase some of the items during iteration.
```js
// find all elements with keys between 10 and 20 inclusive
let prevIter;
for (let it = map.lowerBound(10); !it.equals(map.upperBound(20); it.next()) {
if (prevIter !== undefined) {
// Check whether the previous iterator points to key 15
if (prevIter.key === 15) {
// we cannot erase current iterator. This would break iteration process
// But we can modify other items in the container.
map.erase(prevIter);
}
}
prevIter = new Iterator(it); // make a copy of current iterator
}
```
Detailed library documentation is [here.](https://kirusi.github.io/jstreemap)
## Installation

@@ -25,3 +57,3 @@

```js
// Load library.
// Load library which is UMD packed.
const {TreeSet, TreeMap, TreeMultiSet, TreeMultiMap} = require('jstreemap');

@@ -52,2 +84,35 @@

```
In a browser:
```html
<!-- Load library which is UMD packed -->
<script src="jstreemap.js"></script>
<script>
// Classes TreeSet, TreeMap, TreeMultiSet, TreeMultiMap, Iterator, ReverseIterator, JsIterator, JsReverseIterator are globally available
// Create and initialize map.
let map = new TreeMap([[2, 'B'], [1, 'A'], [3, 'C']]);
// Iterate through all key-value pairs
// Note that entries are stored in the ascending order of the keys,
// not in the insertion order as in standard ES6 map
for(let [k,v] of map) {
console.log(`key: ${k}, value: ${v}`);
}
// Expected output:
// key: 1, value: A
// key: 2, value: B
// key: 3, value: C
// Iterate elements in reverse order
for(let [k,v] of map.backward()) {
console.log(`key: ${k}, value: ${v}`);
}
// find all elements with keys between 10 and 20 inclusive
for (let it = map.lowerBound(10); !it.equals(map.upperBound(20); it.next()) {
console.log(`key: ${it.key}, value: ${it.value}`);
}
</script>
```
## Why jstreemap?

@@ -54,0 +119,0 @@ Ordered associative containers are not provided by default with JavaScript. This library provides an efficient implementation where performance of insert, delete and search operations is O(log(n)).

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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