Code Monkey home page Code Monkey logo

es-async's Introduction

*nix build status Windows build status Tests coverage npm version

es-async

ES2017 async functions compiler

Backed by nodent-compiler, compiles async/await syntax into valid ES2016 code.

Installation

$ npm install es-async

CLI usage

Compile JS file using async/await into ES2016 compliant JS file:

npx es-async path-to-es2017-file.js > path-to-es2016-file.js

Programmatical usage

Compile async code directly

const compileAsync = require("es-async");

const es2016Code = compileAsync(es2017Code);

Compile specific file

const compileAsyncFromFile = require("es-async/from-file");

compileFromFile(es2017Filename).then(es2016Code => {
	// Process compiled code
});

Result examples

See online demo. Compilation is handled by preconfigured (to reflect native behavior backed by native promises) nodent-compiler

ES2017ES016
async function asyncAdd(left) {
  return left + (await right);
}
function asyncAdd(left) {
    return new Promise(($return, $error) =>
      Promise.resolve(right).then($await_1 => {
        try {
            return $return(left + $await_1);
        } catch ($boundEx) {
            return $error($boundEx);
        }
      }, $error)
    );
}

Tests

$ npm test

Project cross-browser compatibility supported by:

es-async's People

Contributors

medikoo avatar

Stargazers

 avatar azu avatar  avatar Lan Qingyong avatar

Watchers

 avatar James Cloos avatar  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.