filerw

A node-task compliant read-write interface for local filesystems.

npm install filerw
2 downloads in the last week
2 downloads in the last month

node-filerw

A node-task compliant read-write interface for local filesystems.

API

read(path, options)

Read a file from the local disk and return a promise which resolves to a node-task compliant record.

The options object supports these keys:

  • encoding The encoding of the file to be read.
var filerw = require('filerw');
filerw.read('test/fixtures/foo.txt', { encoding: 'utf8' }).then(function (self) {
  console.log(self.toString()) // 'foo'
});

write(buffer, options)

Save a node-task compliant buffer to the local disk.

The options object supports these keys: n/a

var filerw = require('./lib/filerw');
var file = new Record('tmp/test.txt', 'utf8', 'test file');
filerw.write(file).then(function(self) {
  console.log(self); // file
});
npm loves you