Last active
March 25, 2022 12:45
-
-
Save rasolofonirina/ca5474f7c90fbae604dc30290ce2f710 to your computer and use it in GitHub Desktop.
blocking vs non-blocking
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
// Blocking | |
const fs = require('fs') | |
const data = fs.readFileSync('/file.txt') | |
console.log(data) | |
// Non-blocking | |
const fs = require('fs') | |
fs.readFile('/file.txt', (err, data) => { | |
if (err) throw err | |
console.log(data) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment