from2
Usage
stream = from2([opts], read)
stream = from2([opts], read)var from = require('from2')
function fromString(string) {
return from(function(size, next) {
// if there's no more content
// left in the string, close the stream.
if (string.length <= 0) return next(null, null)
// Pull in a new chunk of text,
// removing it from the string.
var chunk = string.slice(0, size)
string = string.slice(size)
// Emit "chunk" from the stream.
next(null, chunk)
})
}
// pipe "hello world" out
// to stdout.
fromString('hello world').pipe(process.stdout)stream = from2.obj([opts], read)
stream = from2.obj([opts], read)createStream = from2.ctor([opts], read)
createStream = from2.ctor([opts], read)See Also
License
Last updated
