Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support simple asynchronous operations #3

Merged
merged 14 commits into from
Jun 17, 2022
Prev Previous commit
Next Next commit
test loop async
  • Loading branch information
toyobayashi committed Jun 16, 2022
commit d6dad6cb1eef8ad7b9fbb0e0c1a2250cea899694
11 changes: 11 additions & 0 deletions packages/test/async/async.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ async function main () {
}))
})

const iterations = 500
let x = 0
const workDone = common.mustCall((status) => {
assert.strictEqual(status, 0)
console.log(status)
if (++x < iterations) {
setImmediate(() => test_async.DoRepeatedWork(workDone))
}
}, iterations)
test_async.DoRepeatedWork(workDone)

await new Promise((resolve) => {
setTimeout(resolve, 4000)
})
Expand Down