node.js Convert Blocking

Share:
Everyone don't knows why important to write non-blocking programs in Node.js. Here is some code using non-blocking function "readFile()"

Read the contents of 'index.html' and log them to the console.

 var fs = require('fs');  
 fs.readFile('index.html', function(err, contents){  
  console.log(contents);  
 });  

No comments

'; (function() { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })();

Ads