try-stream-push
Push the return value of the function to the stream, or make the stream emit the thrown error
var through = ;var tryStreamPush = ; { return through;};
It is useful to implement _transform
method of a transform stream.
Installation
npm
npm install try-stream-push
bower
bower install try-stream-push
API
var tryStreamPush = ;
tryStreamPush(stream, fn [, errorHandler])
stream: Object
(stream)
fn: Function
errorHandler: Function
Return: Boolean
(the same as the return value of readable.push()
when the function doesn't throw, otherwise the same as emitter.emit()
's)
It calls the function passed to the second argument.
If the function doesn't throw, it pushes the return value of the function to the stream passed to the first argument.
If the function throws an error, it makes the stream emit the error.
var through = ;var tryStreamPush = ; var all = data: error: ; var stream = through ; ; ; ; stream; stram;
errorHandler(error)
error: Error
Takes the thrown error object and modifies it before emitting.
var gutil = ;var through = ;var tryStreamPush = ; var stream = through;
License
Copyright (c) 2014 Shinnosuke Watanabe
Licensed under the MIT License.