Created
May 9, 2018 04:43
-
-
Save deleteman/84f19b74dfc6b46fc15e62ef64e95218 to your computer and use it in GitHub Desktop.
Event loop showcase
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 request = require("request"), | |
fibonacci = require("fibonacci"), | |
fs = require("fs"); | |
process.nextTick(() => { | |
process.stdout.write("NT #1\n"); | |
}); | |
fs.readFile("./index.js", (err, data) => { | |
process.stdout.write("1: I/O Polling...\n"); | |
}); | |
request.get("http://google.com", (err, res, body) => { | |
process.stdout.write("2: System polling...\n"); | |
}) | |
setImmediate(() => { | |
process.stdout.write("3: Set Immediate phase...\n"); | |
}); | |
setTimeout(() => { | |
process.stdout.write("4: Timers...\n"); | |
}, 0); | |
process.stdout.write("5: Fibonacci(20): " + fibonacci.iterate(20).number + " - Callback\n"); | |
process.nextTick(() => { | |
process.stdout.write("NT #2\n"); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment