Zombie Navigator API (ZAPI) documentation
- Version:
- 0.5.0
- Copyright:
- Copyright © 2015 Zombie Navigator Developers
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see http://www.gnu.org/licenses/.
The latest version of the GNU AGPL should be available here: https://www.gnu.org/licenses/agpl.html
- Copyright © 2015 Zombie Navigator Developers
- License:
- AGPL-3.0+
- Source:
Methods
(inner) delay(s) → {Promise}
Asynchronous sleep using Promise
Parameters:
Name | Type | Description |
---|---|---|
s | number | The 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:
Name | Type | Description |
---|---|---|
genFunction | function | Generator (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
});