SHARE
TWEET

Untitled

a guest Apr 19th, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top