Last active
December 24, 2018 18:57
-
-
Save rajikaimal/ec8ca90fd891bf4f05aa83c218cf755b to your computer and use it in GitHub Desktop.
setTimeout vs setImmediate within an I/O cycle
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
const fs = require("fs"); | |
fs.readFile(__filename, () => { | |
setTimeout(() => { | |
console.log('SetTimeout callback'); | |
}, 0); | |
setImmediate(() => { | |
console.log('SetImmediate callback'); | |
}); | |
}); | |
// Output: | |
// SetImmediate callback | |
// SetTimeout callback |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment