Converts a string to a readable stream.
$ npm install flow-from-stringFor use in the browser, use browserify.
To use the module,
varfromString=require('flow-from-string');Returns a readable stream where each emitted datum is a character from the input string.
To convert a string to a readable stream,
varstream=fromString('beep');To set the readable stream options,
varopts={'objectMode': true,'encoding': 'utf8','highWaterMark': 8};stream=fromString('beep',opts);Returns a reusable stream factory. The factory method ensures streams are configured identically by using the same set of provided options.
varopts={'objectMode': true,'encoding': 'utf8','highWaterMark': 8};varfactory=fromString.factory(opts);varstreams=newArray(10),str;// Create many streams configured identically but reading different strings...for(vari=0;i<streams.length;i++){str='';for(varj=0;j<100;j++){str+=String.fromCharCode(97+Math.floor(Math.random()*26));}streams[i]=factory(str);}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.
varfromString=require('flow-from-string').objectMode;fromString('beep').pipe(process.stdout);varappend=require('flow-append').objectMode,fromString=require('flow-from-string');// Create a string...varstr='';for(vari=0;i<200;i++){str+=String.fromCharCode(97+Math.floor(Math.random()*26));}// Create a readable stream:varreadableStream=fromString(str);// Pipe the data:readableStream.pipe(append('\n')).pipe(process.stdout);To run the example code from the top-level application directory,
$ node ./examples/index.jsUnit tests use the Mocha test framework with Chai assertions. To run the tests, execute the following command in the top-level application directory:
$ make testAll new feature development should have corresponding unit tests to validate correct functionality.
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-covIstanbul creates a ./reports/coverage directory. To access an HTML version of the report,
$ open reports/coverage/lcov-report/index.htmlCopyright © 2014. Athan Reines.