read-array
Converts an array to a readable stream.
DEPRECATED: use flow-from-array.
Installation
$ npm install flow-read-array
For use in the browser, use browserify.
Usage
To use the module,
var readArray = ;
readArray( arr[, options] )
Returns a readable stream
where each emitted datum is an element from the input array
.
To convert an array
to a readable stream,
var stream = ;
To set the readable stream options
,
var opts ='objectMode': true'encoding': 'utf8''highWaterMark': 8;stream = ;
readArray.factory( [options] )
Returns a reusable stream factory. The factory method ensures streams are configured identically by using the same set of provided options
.
var opts ='objectMode': true'encoding': 'utf8''highWaterMark': 8;var factory = readArray;var streams = 10data;// Create many streams configured identically but reading different datasets...for var i = 0; i < streamslength; i++data = 100 ;for var j = 0; j < datalength; j++data j = Math;streams i = ;
readArray.objectMode( arr[, options] )
This method is a convenience function to create readable streams which always operate in objectMode
. The method will always override the objectMode
option in options
.
var readArray = objectMode;;
Examples
var toString =append = objectModereadArray = ;// Create some data...var data = 1000 ;for var i = 0; i < datalength; i++data i = Math;// Create a readable stream:var readStream = ;// Pipe the data:readStream;
To run the example code from the top-level application directory,
$ node ./examples/index.js
Notes
This stream is a Streams2 version of event-stream and its readArray()
method.
Tests
Unit
Unit tests use the Mocha test framework with Chai assertions. To run the tests, execute the following command in the top-level application directory:
$ make test
All new feature development should have corresponding unit tests to validate correct functionality.
Test Coverage
This repository uses Istanbul as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:
$ make test-cov
Istanbul creates a ./reports/coverage
directory. To access an HTML version of the report,
$ open reports/coverage/lcov-report/index.html
License
Copyright
Copyright © 2014. Athan Reines.