Skip to content

Instantly share code, notes, and snippets.

@terinjokes
Created February 10, 2014 00:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save terinjokes/8908191 to your computer and use it in GitHub Desktop.
Save terinjokes/8908191 to your computer and use it in GitHub Desktop.
Showing an example readable stream created from a string
var Readable = require('stream').Readable
module.exports = function string2Stream(string) {
var stream = new Readbale();
stream._read = function() {
//todo: you might want to return data based on the 'size' parameter.
stream.push(string);
string = null;
}
return stream;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment