New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

flow-read

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flow-read

Thin wrapper for graceful-fs file read stream.

latest
Source
npmnpm
Version
0.0.4
Version published
Maintainers
1
Created
Source

flow-read

Thin wrapper for graceful-fs file read stream.

Installation

$ npm install flow-read

API

To create a readStream factory,

var readStream = 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:

var stream = 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:
var readStream = require( 'flow-read' );

// Create a new stream, passing along an optional error handler:
var stream = readStream()
	.path( __dirname + '/path/to/file.json' )
	.stream( onError );

// Pipe the stream:
stream.pipe( process.stdout );

// Error handler:
function onError( error ) {
	if ( error ) {
		console.error( error.stack );
		throw new Error( '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 © 2014. Athan Reines.

Keywords

stream

FAQs

Package last updated on 27 Jul 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts