Runkit
Runkit
home page
user forum
new notebook
clone notebook
download notebook
support & documentation
log in
sign up
new notebook
help & feedback
clone this notebook
download this notebook
Sign In
Sign Up
RunKit + npm: await_once
node v8.17.0
endpoint
share
tweet
var once = require("await_once") let util = require('util'); async function myFunc1(){ console.log('before setTimeout'); await util.promisify(setTimeout)(1000); let ret = Math.random(); console.log('after setTimeout will return ' + ret); return ret; } async function main(label){ let ret = await once('my_name1', myFunc1); console.log('task ' + label + ', ret = ' + ret); } setTimeout(function(){ main(2) }, 3000); main(0); main(1);
Created from: https://npm.runkit.com/await_once
Loading…
Clone and edit this document