Skip to content

Latest commit

History

16 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

flow-read

Thin wrapper for graceful-fs file read stream.

Installation

$ npm install flow-read

API

To create a readStream factory,

varreadStream=require('flow-read'),rStream=readStream();

rStream.path( [filepath] )

This method is a setter/getter. If no filepath is provided, returns the filepath. You configure the stream factory by specifying a filepath:

rStream.path('path/to/file');

rStream.stream( [clbk] )

Provided a filepath has been specified, to create a new readStream:

varstream=rStream.stream(clbk);

Where the optional clbk is invoked upon stream end and has an error as its first argument. If no read errors, error is null.

Usage

Methods are chainable:

readStream().path('path/to/file').stream(clbk).pipe(process.stdout);

Examples

// File read stream generator:varreadStream=require('flow-read');// Create a new stream, passing along an optional error handler:varstream=readStream().path(__dirname+'/path/to/file.json').stream(onError);// Pipe the stream:stream.pipe(process.stdout);// Error handler:functiononError(error){if(error){console.error(error.stack);thrownewError('Error!!!');}console.log('Finished!');}

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

MIT license.


Copyright

Copyright © 2014. Athan Reines.

About

Wrapper for (graceful-fs) file read stream.

Resources

Stars

2 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages