This package has been deprecated

Author message:

This package is deprecated. Please use the 'insort' package instead.

tidymap

0.1.0 • Public • Published

TidyMap

JavaScript (ES6) Map subclass that efficiently maintains a sorted iteration order.

Usage

let TidyMap = require('tidymap');
// => [Function: TidyMap]

let m = new TidyMap([[42, 'foo'], [99, 'bar'], [0, 'quux']],
                       (a, b) => a - b); // default cmp uses localeCompare
// => TidyMap { 0 => 'quux', 42 => 'foo', 99 => 'bar' }

m.set(59, 'spam');
// => TidyMap { 0 => 'quux', 42 => 'foo', 59 => 'spam', 99 => 'bar' }

Requirements

  • ES6

Features

  • Simple and small
  • Standard ES6 Map interface
  • Space efficient (adds an extra O(n) sorted Array of key references)
  • Time efficient (O(log(n)) inserts and deletes)

Caveats

  • This works fine for a few thousand entries, but for larger datasets you probably want something fancier like a skip list.

Package Sidebar

Install

npm i tidymap

Weekly Downloads

1

Version

0.1.0

License

MIT

Last publish

Collaborators

  • wemoloh