Module: utils/co

Methods

(inner) co(generator) → {function}

Wrap a generator function to be executed into a function that returns a promise.

Parameters:
Name Type Description
generator GeneratorFunction
Source:
Returns:
Type
function

(inner) cob(generator) → {function}

Wrap a generator function to be executed into a function that accepts a node.js style callback.

Parameters:
Name Type Description
generator GeneratorFunction
Source:
Returns:
Type
function

(inner) every(jobs) → {Promise}

Execute each promise and have them pass a truth test.

Parameters:
Name Type Description
jobs Array:.<Promise:>
Source:
Returns:
Type
Promise

(inner) exec(gen) → {Promise}

Execute an instantiated generator.

Parameters:
Name Type Description
gen Generator
Source:
Returns:
Type
Promise

(inner) isPromise(obj) → {Boolean}

Test whether an object is a promise.

Parameters:
Name Type Description
obj Object
Source:
Returns:
Type
Boolean

(inner) job() → {Job}

Create a job object.

Source:
Returns:
Type
Job

(inner) promisify(func, ctxnullable) → {function}

Wrap a function that accepts node.js style callbacks into a function that returns a promise.

Parameters:
Name Type Attributes Description
func function
ctx Object <nullable>
Source:
Returns:
Type
function

(inner) spawn(generator, ctx) → {Promise}

Execute generator function with a context and execute.

Parameters:
Name Type Description
generator GeneratorFunction
ctx Object
Source:
Returns:
Type
Promise

(private, inner) tick(resolve, reject)

Wait for a nextTick.

Parameters:
Name Type Description
resolve function
reject function
Source:

(inner) timeout(time) → {Promise}

Wait for a timeout with a promise.

Parameters:
Name Type Description
time Number
Source:
Returns:
Type
Promise

(inner) wait() → {Promise}

Wait for a nextTick with a promise.

Source:
Returns:
Type
Promise

(inner) wrap(resolve, reject) → {function}

Wrap resolve and reject into a node.js style callback.

Parameters:
Name Type Description
resolve function
reject function
Source:
Returns:
Type
function