Skip to content

Examples demonstrating the usage of ECMAScript 2018 async functions

Notifications You must be signed in to change notification settings

jakepeyser/async-functions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

async-functions

This repo contains code examples of JavaScript async functions and their predecessors in the JS language. It is meant as a reference point for understanding the importance and context of this new pattern.

These code snippets were originally created as collateral for the blog post I wrote titled Where Did Async/Await Come from and Why Use It?.

These snippets represent the different stages of the evolution of asynchronous operation invocation in the JavaScript language: Callbacks, Promises, and Async Functions. Each file retrieves a joke using the Chuck Norris API and its respective async pattern.

# Callbacks -> Promises -> Async Functions
npm run callbacks
npm run promises
npm run async

The sync-style and error-handling files demonstrate improvements that async functions bring to JavaScript. Each file contains how the pattern was formerly implemented using promises alone (commented out), along with how async functions can be utilized to implement the same functionality while improving readability, code flow, and error handling.

# Demonstrate the synchronous-looking style that async functions provide
npm run sync

# Demonstrate the improvements in asynchronous error handling
npm run errors

About

Examples demonstrating the usage of ECMAScript 2018 async functions

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published