Skip to content

Instantly share code, notes, and snippets.

View jackpordi's full-sized avatar

Jack Pordi jackpordi

View GitHub Profile
makeSoup();
makePasta();
async function makeSoup() {
const pot = boilPot();
chopCarrots();
chopOnions();
await pot;
addCarrots();
await letPotKeepBoiling(5);
addOnions();
await letPotKeepBoiling(10);
function makeSoup() {
const pot = boilPot();
chopCarrots();
chopOnions();
await pot;
addCarrots();
await letPotKeepBoiling(5);
addOnions();
await letPotKeepBoiling(10);
console.log("Your vegetable soup is ready!");
@jackpordi
jackpordi / awaitExample.js
Created September 3, 2019 22:39
Await example
async function asyncFunction() {
/* Returns a promise... */
}
result = await asyncFunction();
async function letPotKeepBoiling(time) {
return /* A promise to let the pot keep boilng for certain time */
}
async function boilPot() {
return /* A promise to let the pot boil for time */
}
@jackpordi
jackpordi / syncFunctions.js
Created September 3, 2019 22:34
Asynchronous medium article
function chopCarrots() {
/**
* Some long computational task here...
*/
console.log("Done chopping carrots!");
}
function chopOnions() {
/**
function makeSoup() {
const pot = boilPot();
chopCarrots();
chopOnions();
await pot;
addCarrots();
await letPotKeepBoiling(5);
addOnions();
await letPotKeepBoiling(10);
console.log("Your vegetable soup is ready!");