WBE_Praktikum_5/code/async/nexttick.js

22 lines
334 B
JavaScript

//
// nexttick vs. immediate and timeout events
//
const fs = require('fs')
const process = require('process')
fs.readFile("nexttick.js", () => {
setTimeout(() => {
console.log('timeout')
}, 0)
setImmediate(() => {
console.log('immediate')
})
process.nextTick(() => {
console.log('nexttick')
})
})