nodejs async test created by crazy4groovy - https://repl.it/NPK6/4
async function a() {
let a = await Promise.resolve(1)
console.log(2, a) // "2 1"
}
a()
function PromisePlus() {
let resolve, reject;
return { promise: new Promise((...args) => { [resolve, reject] = args; }), resolve, reject }
}
const { promise, resolve, reject } = PromisePlus();
console.log(typeof promise, typeof resolve, typeof reject)
promise.then(data => console.log(3, data)) // "3 42"
resolve(42)
console.log(1, ' START (and wait)')