Coder Social home page Coder Social logo

async-functions's Introduction

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

async-functions's People

Contributors

jakepeyser avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.