Cacheable file system methods for holding file reads in memory
var cfs = require('cacheable-fs');
// Promise style
cfs.cache.readFile('path/to/file.txt').then(function(content) {
// ... do something with content
});
// Stream style
cfs.cache.createReadStream('path/to/file.txt')
.pipe( ... );
All of the following methods will return a promise
cache.readFile(path)
- Read a filecache.concat(files)
- Concatenates an array of filescache.copy(path)
- Copies a file from one location to another creating directoriesreadFile(path, [...])
- Promisified wrapper to fs.readFilewriteFile(path, [...])
- Promisified wrapper to fs.writeFile
cache.createReadStream(path)
- Read a file (returns a stream)cache.expire(path)
- Expire a given path from cachecache.getCache()
- Returns the raw cache object (debugging)cache.watch(fn)
- Watch the file system and trigger a callback on each change or deletion. Callback isfn(eventName, path)
.cache.unwatch()
- Stop watching the file system
fs
- Exposing graceful-fs