rightco
Wrap righto
in a Promise
,
for use as a replacement for co
.
Installation
npm install --save rightco righto
Note that righto
is a peer dependency.
Usage
;
Where something
and somethingElse
are either:
a thenable,
or an errback.
As such use rightco
to run your generator functions,
where you need them to be wrapped in a Promise
.
thenable
A Promise
is a thenable.
let thenable = { // call either `resolve(result)` for success, // or `reject(error)` for failure};
errback
Any function which has a callback function as its last parameter; and this callback function takes an error as its first parameter, and results as subsequent parameters is an errback.
let { // call either `callback(undefined, result)` for success, // or `callback(error)` for failure};
The latter is the more interesting use case,
as rightco
enables the use of generator functions to yield
a standard errback when wrapped with righto
:
;
See the test spec files for detailed usage examples.
Author
Licence
GPL-3.0