You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+21-7Lines changed: 21 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,16 @@
1
1
fast-async
2
2
==========
3
3
4
-
'fast-async' is a _Babel v6.x.x_ plugin that implements the ES7 keywords `async` and `await` using syntax transformation
4
+
'fast-async' is a _Babel v6.x.x_ plugin that implements the ES7 keywords `async` and `await` using syntax transformation
5
5
at compile-time rather than generators.
6
6
7
-
The main reason for using 'fast-async' as opposed to Babel's default implementation of async/await is
7
+
The main reason for using 'fast-async' as opposed to Babel's default implementation of async/await is
8
8
performance (https://github.com/MatAtBread/nodent#performance) - it's 3-4 times faster in a browser/node, and
9
9
as much as 10 times faster on a mobile browsers, mainly due to avoiding generators (and therefore regenerator).
10
10
11
11
There's a simple test (that just makes sure the plugin works and generates code that runs). More complete
12
12
test coverage is included with nodent.
13
13
14
-
fast-async (via nodent) can generate code suitable for use in early Browsers with no Promise support (as well as no generators),
15
-
and has various options for turning sourcemaps on/off and controlling code generation, however for now it simply chooses some defaults.
16
-
17
14
Because Babel parses the code, the ES7 extensions possible with nodent (`await` anywhere, `async return` and `async throw`) are not supported, however full implementation of `async function` containing `await` expressions is implemented.
From the installation directory (e.g. node_modules/fast-async):
29
26
30
27
npm test
31
28
29
+
Options
30
+
-------
31
+
The plugin accepts the following options object, which itself is optional, as are all members. These are based on the options in nodent,
32
+
but since much of the parsing is done by Babel some are unused.
33
+
34
+
env:{
35
+
log:function(string), // Supplied routine to emit transformation warnings. Default: console.log
36
+
augmentObject:false, // Add the nodent utilities asyncify() and isThenable() to Object.prototype
37
+
dontMapStackTraces:false, // Don't install the stack trace hook that maps line numbers
38
+
asyncStackTrace:false, // Provide async stack traces
39
+
dontInstallRequireHook:false // Don't transform all JS files as they are loaded into node
40
+
},
41
+
compiler:{
42
+
promises:true, // Use nodent's "Promises" mode. Set to false if your execution environment does not support Promises.
43
+
generators:false // Transform into 'Generators'.
44
+
}
45
+
46
+
For more information on the compiler options, see [ES7 and Promises](https://github.com/matatbread/nodent#es7-and-promises) in the nodent documentation.
32
47
33
48
Useful Links
34
49
------------
@@ -41,4 +56,3 @@ Online performance checkers:
41
56
*[nodent](http://nodent.mailed.me.uk/#function%20pause%28%29%20{%0A%20%20%20%20return%20new%20Promise%28function%20%28%24return%2C%20%24error%29%20{%0A%20%20%20%20%20%20%20%20setTimeout%28function%20%28%29%20{%0A%20%20%20%20%20%20%20%20%20%20%20%20return%20%24return%280%29%3B%0A%20%20%20%20%20%20%20%20}%2C%200%29%3B%0A%20%20%20%20}%29%3B%0A}%0A%0Aasync%20function%20doNothing%28%29%20{%0A%20%20%20%20return%3B%0A}%0A%0Aasync%20function%20test%28%29%20{%0A%20%20%20%20var%20t%20%3D%20Date.now%28%29%3B%0A%20%20%20%20for%20%28var%20j%20%3D%200%3B%20j%20%3C%2050%3B%20j%2B%2B%29%20{%0A%20%20%20%20%20%20%20%20for%20%28var%20i%20%3D%200%3B%20i%20%3C%201000%3B%20i%2B%2B%29%20{%0A%20%20%20%20%20%20%20%20%20%20%20%20await%20doNothing%28%29%3B%0A%20%20%20%20%20%20%20%20}%0A%20%20%20%20%20%20%20%20await%20pause%28%29%3B%0A%20%20%20%20}%0A%20%20%20%20return%20Date.now%28%29%20-%20t%3B%0A}%0A%0Atest%28%29.then%28alert%29%3B%0A) 632ms (and shave off another 100ms by selecting 'Pure ES5' mode)
0 commit comments