Transform viewer
The input and the output of the Babel preset of the library for six examples.
The examples
Select an example. The left pane shows the input. The right pane shows the output of the preset. The build of this site makes the output with the real preset of the repository.
What to look for
- Each async function becomes a generator function that
coroutine()wraps. Eachawaitbecomes ayield. The name of the async function is the second argument ofcoroutine(), for the callback hooks. - The function keeps its name and its parameters. A declaration stays a declaration, so it stays hoisted.
- A generator gives
bindGenerator(...). The body moves into an inner generator. - An async generator becomes a generator function that
asyncGenerator()wraps. Eachawaitbecomesyield _awaitAsyncGenerator(...). - The output imports the functions that it uses from
async-browser-context/runtime, for examplecoroutine,bindGenerator,asyncGeneratorandawaitAsyncGenerator.
The transform page tells what the runtime does at each step.