Let asynchronous I/O happen by returning control back to the event loop

added by JavaScript Kicks
12/4/2015 4:44:09 PM

574 Views

When a newcomer to Node.js first writes a file reading program, it comes out something like this. var fs = require('fs'); var fileContents; fs.readFile(filename, utf8, function(err, data) { fileContents = data; }); while (!fileContents) { // wait until the file contents is filled } // then print the


0 comments