flow-write
Thin wrapper for graceful-fs file write stream.
Installation
$ npm install flow-write
API
To create a writeStream factory,
var writeStream =wStream = ;
wStream.path( [filepath] )
This method is a setter/getter. If no output filepath
is provided, returns the output filepath
. You configure the stream factory by specifying an output filepath
:
wStream;
wStream.stream( [clbk] )
Provided a filepath
has been specified, to create a new writeStream:
var stream = wStream;
Where the optional clbk
is invoked upon stream end
and has an error
as its first argument. If no write errors, error
is null
.
Usage
Methods are chainable:
var stream =;readStream;
Examples
var eventStream =writeStream = ;// Create some data...var data = 1000 ;for var i = 0; i < datalength; i++data i = Math;// Create a readable stream:var readStream = eventStream;// Create a new stream, passing along an optional error handler:var stream =;// Pipe the data to the stream...readStream;// Error handler:{if errorconsole;throw 'Error!!!' ;console;}
Tests
Unit tests use the Mocha test framework with Chai assertions.
Assuming you have installed Mocha, execute the following command in the top-level application directory to run the tests:
$ mocha
All new feature development should have corresponding unit tests to validate correct functionality.
License
Copyright
Copyright © 2014. Athan Reines.