Created
January 12, 2017 06:51
-
-
Save pi0/dacf02ac2af79b3b53094770d0e91c15 to your computer and use it in GitHub Desktop.
Node 7.4 Async/Await
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node --harmony test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function await_me() { | |
return new Promise((resolve,reject)=> { | |
setTimeout(()=>{ | |
console.log("After some time"); | |
resolve(); | |
},1000); | |
}) | |
} | |
async function test() { | |
console.log("A"); | |
await await_me(); | |
console.log("B"); | |
} | |
test(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment