from-string
Converts a string to a readable stream.
Installation
$ npm install flow-from-string
For use in the browser, use browserify.
Usage
To use the module,
var fromString = ;
fromString( str[, options] )
Returns a readable stream
where each emitted datum is a character from the input string
.
To convert a string
to a readable stream,
var stream = ;
To set the readable stream options
,
var opts ='objectMode': true'encoding': 'utf8''highWaterMark': 8;stream = ;
fromString.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 = fromString;var streams = 10str;// Create many streams configured identically but reading different strings...for var i = 0; i < streamslength; i++str = '';for var j = 0; j < 100; j++str += String;streams i = ;
fromString.objectMode( str[, 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 fromString = objectMode;;
Examples
var append = objectModefromString = ;// Create a string...var str = '';for var i = 0; i < 200; i++str += String;// Create a readable stream:var readableStream = ;// Pipe the data:readableStream;
To run the example code from the top-level application directory,
$ node ./examples/index.js
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.