1.1.0 • Published 5 years ago

callbag-safe-pipe v1.1.0

Weekly downloads
5
License
MIT
Repository
github
Last release
5 years ago

callbag-safe-pipe

Callbag utility like callbag-pipe but wraps the operators calls in a tryCatch block, sending an eventual exception to the sink. Check out the tests for more details.

npm install callbag-safe-pipe

Examples

Catch error thrown in the map operator

const map = require('callbag-map');
const fromIter = require('callbag-from-iter');
const subscribe = require('callbag-subscribe');
const safePipe = require('callbag-safe-pipe');

safePipe(
  fromIter([0, 1, 2]),
  map(x => x.thisIsUndefined.y),
  subscribe({
    next() {},
    error(err) {
      console.log(err.message) // Cannot read property 'b' of undefined
    }
  })
);
1.1.0

5 years ago

1.0.0

5 years ago