jack e1a2621c78 update | 2 years ago | |
---|---|---|
.. | ||
test | 2 years ago | |
.jshintrc | 2 years ago | |
.npmignore | 2 years ago | |
.testem.json | 2 years ago | |
.travis.yml | 2 years ago | |
LICENCE | 2 years ago | |
README.md | 2 years ago | |
index.js | 2 years ago | |
package.json | 2 years ago |
Cache a continuable
var cache = require("continuable-cache")
var fs = require("fs")
var readFile = function (uri) { return function (cb) {
fs.readFile(uri, cb)
} }
var continuableFile = readFile("./package.json")
var cached = cache(continuableFile)
// will only do one file read operation
cached(function (err, file) {
/* calls out to fs.readFile */
})
cached(function (err, file) {
/* get's either err or file from cache in cached */
})
npm install continuable-cache