Async function memoizer.
$ npm install memoize-async
memoize = require('memoize-async')
readFile = require('fs').readFile
memoized = memoize(readFile)
memoized('docs/readme', console.log)
// doing some work
// => read me first!
memoized('docs/readme', console.log)
// => read me first!
It stores the values returned in an object by default. You can pass read & write methods to choose your own:
memoized = memoize(fn, { read: read, write: write, hash: ifexists })
function read (key, callback) {
}
function write (key, value, callback) {
}