TupleMap
A Map which accepts multiple objects as a key. This lib is one of the several possible cache for memoize-immutable, but it can suit other use-cases as it implements a usual Map API.
Install
npm install --save TupleMap
This lib has no dependency, but requires a native implementation of Map.
Usage
var TupleMap = ; // When the `limit` option is set, TupleMap turns into an LRU cache.// Clearing the map every X seconds can also be an acceptable strategy sometimes.var cache = limit: 10000 ; var keyPart1 = {};var keyPart2 = 'yolo';var keyPart3 = ;var value = any: 'thing'; // Note that following keyPart tuples are wrapped in new arrays that are !==// (otherwise a Map would have been enough).cache; cache === true;cache === value;
When should you use this map?
This map should be used with functions that take more than one argument. It is a less efficient but more flexible alternative to WeakTupleMap.
Author
License
MPL-2.0