Examples to show techniques to archieve particular tasks via
Ordered by level of complexity.
async marks a function as asynchronous, the function will always return a Promise, resolving
with the return value.
await handles Promises inside the async function, making the
function’s inner logic synchronous.
async/await only blocks execution of that function, however other functions can still execute
while it is waiting. Thus developers still can leverage Node.js concurrency.
To ensure all dependencies are installed run the below after cloning the repo.
Run each example directly i.e.
node 01-basics.js and edit to your delight and observe what
To see how promises get executed/resolved/rejected under the hood run with the
DEBUG=task node 01-basics.js
To run an example in your browser run it with the included budo, i.e.:
npm run budo -- 01-basics.js
This allows you to add breakpoints, observe stack traces, etc. to understand how things work
under the hood and also to convince yourself that
async/await code is easily debuggable.
- 6 reasons why async/await blows promises away
- modern modules in which @mikeal also talks about the advantages of async/await over other async flow control patterns
- comparison of promises/callbacks vs async/await
- awesome promises
- promise fun tons of useful promise libraries
lots of which can be consumed via
- node.js core util promisify implementation
- pify promisify with more features and magic