JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 694
  • Score
    100M100P100Q80674F
  • License MIT

Like ES6 Map but with paths instead of keys

Package Exports

  • pmap

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (pmap) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

pmap

A PMap has the same API surface as an es'15 Map, except keys are arrays describing paths into a logical tree structure. Here are some examples.

import PMap from 'pmap';

const map = new PMap();

map.set(['a','b','c'], 2);

// . (empty)
// └--a (empty)
//    └--b (empty)
//       └--c (2)

map.set(['a','x'], 3);

// . (empty)
// └--a (empty)
//    |--b (empty)
//    |  └--c (2)
//    └--x (3)

map.set(['a'], 9);

// . (empty)
// └--a (9)
//    |--b (empty)
//    |  └--c (2)
//    └--x (3)

map.set([], null);

// . (null)
// └--a (9)
//    |--b (empty)
//    |  └--c (2)
//    └--x (3)

map.delete(['a','b','c']);

// . (null)
// └--a (9)
//    └--x (3)

for (const entry of map) {
  console.log(entry);
}

// [['a'], 9]
// [['a', 'x'], 3]

npm

npm install pmap

API documentation

See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map

Caveat: differs from maps since keys are paths!