Every current browser and Node 8 ship async functions, which means the transform is no longer the reason for a build step — although the build step is still there for everything else.
// promise chain
function load(id) {
return fetch(`/api/orders/${id}`)
.then(res => res.json())
.then(order => enrich(order));
}
// the same thing
async function load(id) {
const res = await fetch(`/api/orders/${id}`);
const order = await res.json();
return enrich(order);
}
The gain is that a conditional or a loop inside the chain stops being a nesting problem. Note that await is only legal inside an async function — there is no top-level await — so the entry point is still a function call, and forgetting to handle its rejection produces an unhandled promise rejection rather than an error anybody sees.