capta
v0.2.0
Published
Capture promise value for ad-hoc use
Downloads
2
Maintainers
Readme
capta
npm install capta
Capta was born to make playing with promise in REPL easier.
It will tell you when the promise is resolved
and store the value in obj._
.
$ node
> var cap = require('capta');
> var result = cap(somePromise);
// wait a bit...
Promise captured!
> result._
'some value'
When the promise encounters an error,
it will be stored in obj.err
.
$ node
> var cap = require('capta');
> var result = cap(someBrokenPromise);
// wait a bit...
Promise error!
> result.err
'some error'
If you know the promise will return multiple arguments,
use cap.spread
or cap.all
:
$ node
> var cap = require('capta');
> var result = cap.spread(somePromise);
// wait a bit...
Promise captured!
> result._
['some value']