Abort groups of callbacks.
This is a handy module for cancelling nested asynchronous logic when some external event comes along like a timeout that should abort an entire transaction.
Toss is like domains in node but implemented as a function wrapper instead of a something in core.
var toss = ;var fs = ;var t =;fs;
var toss = require('toss')
Create a toss function
t with an optional
timeout and an optional error
cb fires when a callback is attempted after
t.end() is called
t.error() is explicitly called.
timeout is specified and
t.end() hasn't been called in
t.end() will be called automatically.
Returns a function that calls
cb with the arguments provided unless
has been called, in which case the callback from
toss() is called.
Put this function around the callbacks that you want to group together.
After this function is called, all calls to functions wrapped with
t() will be
ignored and the callback from
toss() will fire.
t.end() then triggers the callback from
toss() with the
With npm do:
npm install toss