Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. // Blocking
  2. const fs = require('fs');
  3. const data = fs.readFileSync('/file.md'); // blocks here until file is read
  4. console.log(data);
  5. moreWork(); // will run after console.log
  6.  
  7. // Non-blocking
  8. const fs = require('fs');
  9. fs.readFile('/file.md', (err, data) => {
  10. if (err) throw err;
  11. console.log(data);
  12. });
  13. moreWork(); // will run before console.log
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement