@dopt/mercator
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

@dopt/mercator

A Map implementation that allows for objects as keys without key equality constraints. In practice this means

const map = new Mercator();
map.set([1,2], 'a');
map.get([1,2]);
> 'a'

whereas a standard Map would have the following behavior

const map = new Map();
map.set([1,2], 'a');
map.get([1,2]);
> undefined

Standard maps use a key equality SameValueZero algorithm. Mercator instead calls JSON.stringify on the key and uses it as the key for its underlying map.

Great for in memory data structures where the key is naturally a composite (like an array or an object).

Readme

Keywords

none

Package Sidebar

Install

npm i @dopt/mercator

Weekly Downloads

0

Version

1.0.2

License

MIT

Unpacked Size

10.1 kB

Total Files

10

Last publish

Collaborators

  • kseth
  • alexchantastic
  • pankaj-avhad-dopt
  • chasebish
  • joemckenney