highland-errors-to

Redirect errors in a highland stream.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
highland-errors-to
2.0.19 years ago9 years agoMinified + gzip package size for highland-errors-to in KB

Readme

Highland Errors To
Redirect errors in a highland stream.

Install

npm install highland-errors-to

Usage

var _ = require('highland'),
    errorsTo = require('highland-errors-to'),
    things,
    stream,
    errorStream;

stream = _(function(push, next) {
  push(null, 'hello');
  push(new Error('first error'));
  push(null, 'everyone');
  push(new Error('second error'));
  push(null, _.nil);
});

var things = errorsTo(stream);
errorStream = things.errors;
stream = things.stream;

stream
  .errors(function(error, push) {
    // never called, all errors are redirected!
  });

errorStream
  .errors(function(error, push) {
    // called for every error in stream
  });

stream.resume();