@gershy/compound-map
v1.0.8
Published
Like Map, but allows arbitrary sets of values for keys
Readme
CompoundMap
Easily map unordered sets of arbitrary values to corresponding values!
Install
> npm install @gershy/compound-mapExample Usage
import CompoundMap from '@gershy/compound-map';
const cm = new CompoundMap({ width: 3 });
const key1 = {};
const key2 = [];
const key3 = /abc/i;
cm.set([ key1, key2, key3 ], 'lol');
console.log(cm.get([ key1, key2, key3 ])); // 'lol'
console.log(cm.get([ key3, key1, key2 ])); // 'lol'
console.log(cm.get([ key1, key2, {} ])); // undefinedDetails
- Must provide
widthvalue to constructor indicating fixed compound-key size CompoundMapkeys may be any arbitrary valueCompoundMapvalues may be any arbitrary value
