Skip to content

ironikart/cacheable-fs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cacheable FS

Cacheable file system methods for holding file reads in memory

Usage

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( ... );

Methods

Promisified

All of the following methods will return a promise

  • cache.readFile(path) - Read a file
  • cache.concat(files) - Concatenates an array of files
  • cache.copy(path) - Copies a file from one location to another creating directories
  • readFile(path, [...]) - Promisified wrapper to fs.readFile
  • writeFile(path, [...]) - Promisified wrapper to fs.writeFile

Other

  • cache.createReadStream(path) - Read a file (returns a stream)
  • cache.expire(path) - Expire a given path from cache
  • cache.getCache() - Returns the raw cache object (debugging)
  • cache.watch(fn) - Watch the file system and trigger a callback on each change or deletion. Callback is fn(eventName, path).
  • cache.unwatch() - Stop watching the file system

Properties

About

Cacheable file system wrapper for Node

Resources

License

Stars

Watchers

Forks

Packages

No packages published