Module: zombie/async

Zombie Navigator API (ZAPI) documentation
Version:
  • 0.5.0
License:
  • AGPL-3.0+
Source:

Methods

(inner) delay(s) → {Promise}

Asynchronous sleep using Promise
Parameters:
NameTypeDescription
snumberThe number of seconds to sleep for
Source:
Returns:
Type
Promise
Example
const {delay} = require('zombie/async');

(inner) run(genFunction) → {Promise}

Run a generator as a coroutine using Promise
Parameters:
NameTypeDescription
genFunctionfunctionGenerator (coroutine) to run
Source:
Returns:
Type
Promise
Example
const {run} = require('zombie/async');
run(function* () {
	try {
		let result = yield new Promise(...);
	} catch (e) {
		// rejected
	}
	throw new Error();
})
.then(function (result) {
	// generator is finished
})
.catch(function (e) {
	// an error in generator
});