
whoami
λ
What is it? The proposal is mostly finished and now needs feedback from implementations and users to progress further.
async/await// interactiveconst data = getData(param);process(data);
// reactivegetData(param).then(data => process(data));
function getCompanyByUser(userId) {const user = getUser(userId);const company = getCompany(user.companyId);return company;}
function getCompanyByUser(userId) {return getUser(userId).then(user => getCompany(user.companyId));}



Coroutines are computer program components with multiple entry points for suspending and resuming execution at certain locations. Coroutines are well-suited for implementing more familiar program components such as cooperative tasks, exceptions, event loop, iterators, infinite lists and pipes.
In computer science, a generator is a special routine that can be used to control the iteration behaviour of a loop. In fact, all generators are iterators.
function* fib() {let [a, b] = [1, 1];while (true) {yield a;[a, b] = [b, a + b];}}
function* fib(a = 1, b = 1) {yield a;yield* fib(b, a + b);}
const iter = fib();iter.next(); // { value: 1, done: false }iter.next(); // { value: 1, done: false }iter.next(); // { value: 2, done: false }iter.next(); // { value: 3, done: false }iter.next(); // { value: 5, done: false }iter.next(); // { value: 8, done: false }
npm i co
function getCompanyByUser(userId) {const user = getUser(userId);const company = getCompany(user.companyId);return company;}
const getCompanyByUser = co.wrap(function* (userId) {const user = yield getUser(userId);const company = yield getCompany(user.companyId);return company;});
This code works in the newest browsers without any compilation steps.
npm i regenerator
npm i babel
babel-runtime
function getCompanyByUser(userId) {const user = getUser(userId);const company = getCompany(user.companyId);return company;}
async function getCompanyByUser(userId) {const user = await getUser(userId);const company = await getCompany(user.companyId);return company;}
a => f(g(a))async a =>
f(await g(a))

Link to these slides —
alexeyraspopov.github.io/async-await