Package Exports
- awaiting
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (awaiting) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Awaiting
The async/await utility for browsers and Node.js.
Examples
// wait for a second
await a.delay(1000)
// limit a fetch to five seconds
const image = await a.limit(fetch('flowers.jpg'), 5000)
// await events
await a.event(server, 'listen')
// await callbacks
const contents = await a.callback(fs.readFile, 'foo.txt')
// map an array to an async function with 3 instances running in parallel
const pages = await a.map(urls, 3, async url => await fetch(url))
// await successes (ignoring errors)
const optionalFeature = await a.resolution(optionalStep)...and more in the docs.
Installation
In node
Use yarn or npm:
$ yarn add awaiting
$ npm install --save awaitingthen:
const a = require('awaiting')
await a.delay(1000)In a browser
Use browser/awaiting.js:
<script src='awaiting.js'></script>
<script>
const a = awaiting
await a.delay(1000)
</script>Building
$ yarn buildTesting
$ yarn install
$ yarn test
$ yarn test:browser