Skip to content

Commit

Permalink
info
Browse files Browse the repository at this point in the history
  • Loading branch information
antimatter15 committed Aug 16, 2016
1 parent 4730d67 commit b1b6473
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Top Level Await

https://github.com/tc39/ecmascript-asyncawait/issues/9
This is a simple Babel plugin which automatically wraps top-level `await` expressions.

The general approach is to throw stuff into a big async function.
That is, it'll turn code like:

await fetch('http://www.google.com/')

Turns into:
into:

(async function(){
await fetch('http://www.google.com/')
Expand Down Expand Up @@ -36,6 +36,8 @@ This is transpiled conveniently into:
The current implementation doesn't support exports. Top level awaits might interfere with the behavior of certain modules (as many of their exports may not be defined until well after the module has been loaded). Anyway, this top-level await transform is primarily useful for REPL-style interactions, as essentially a convenience to avoid wrapping things with an async IIFE (immediately invoked function expression).


Additional Information: https://github.com/tc39/ecmascript-asyncawait/issues/9

# To Run:

babel-node --presets es2015 transform.js
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "babel-plugin-top-level-await",
"version": "0.5.0",
"description": "babel plugin for automatically wrapping top level awaits",
"main": "index.js",
"main": "dist/top-level-await.js",
"directories": {
"test": "test"
},
Expand Down

0 comments on commit b1b6473

Please sign in to comment.