Eric Foster d5378345de connection between front end and database | 6 年前 | |
---|---|---|
.. | ||
test | 6 年前 | |
.jshintrc | 6 年前 | |
.npmignore | 6 年前 | |
.testem.json | 6 年前 | |
.travis.yml | 6 年前 | |
LICENCE | 6 年前 | |
README.md | 6 年前 | |
index.js | 6 年前 | |
package.json | 6 年前 |
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