Skip to content

Latest commit

 

History

History
36 lines (32 loc) · 1.14 KB

README.md

File metadata and controls

36 lines (32 loc) · 1.14 KB

Build Status Coverage Status license

Allows to put arrays into maps. Works similarly like ES6 Maps.

Install

npm i n-dimensional-map

Example

const NMap = require('n-dimensional-map');
const map = new NMap();
map.set(1, 'a');
map.set(2, 'b');
map.set([2], 'c');
console.log(map); // NMap { (1) => a, (2) => c }
map.set(1, 2, 3, 'd');
console.log(map.get([1, 2, 3])); // d
map.set(1, 5, 'e');
map.set([1, 5], 'f');
console.log(map.get(1, 5)); // f
console.log(map); // NMap { (1) => a, (1, 2, 3) => d, (1, 5) => f, (2) => c }
map.delete(1, 2, 3);
console.log(map); // NMap { (1) => a, (1, 5) => f, (2) => c }
console.log(map.has(1, 2, 3)); // false
console.log(map.has(1, 5)); // true

License

MIT