multikey-map

0.4.0 • Public • Published

NPM version Repository package.json version MIT License Discord

Multikey Map

A simple map implementation that supports multiple keys.

multikey-map uses mixed-map internally, which is a map implementation that uses both Map and WeakMap internally.

Installation

npm install multikey-map

Usage

import MultikeyMap from 'multikey-map';

let map = new MultikeyMap<[string, number], string | undefined>();

map.set(['foo', 0], 'a');
map.set(['foo', 1], 'b');

map.get(['foo', 0]); // 'a'
map.get(['foo', 1]); // 'b'
map.get(['foo', 2]); // undefined
map.has(['foo', 2]); // false
map.hasAndGet(['foo', 2]); // [false, undefined]

map.set(['bar', 0], undefined);

map.get(['bar', 0]); // undefined
map.has(['bar', 0]); // true
map.hasAndGet(['bar', 0]); // [true, undefined]

License

MIT License.

Readme

Keywords

none

Package Sidebar

Install

npm i multikey-map

Weekly Downloads

2,971

Version

0.4.0

License

MIT

Unpacked Size

13.8 kB

Total Files

7

Last publish

Collaborators

  • vilicvane