mem-map
v1.0.1
Published
Map to be used with mem
Maintainers
Readme
mem-map 
Map to be used with mem
Please note that this is not a ponyfill for Map. Although it will use the
native Map implementation if available. If Map is not available, a very lightweight Map is offerred which only implements get, set and has. This is just
enough so it can be used with mem if you want to support older Node versions.
Install
$ npm install --save mem-mapUsage
const Map = require('mem-map');
const mem = require('mem');
let i = 0;
const counter = () => ++i;
const memoized = mem(counter, {cache: new Map()});
memoized('foo');
//=> 1
// cached as it's the same arguments
memoized('foo');
//=> 1
// not cached anymore as the arguments changed
memoized('bar');
//=> 2
memoized('bar');
//=> 2License
MIT © Sam Verschueren
