Wenbin Ma
Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.
var data = file.read('file.data');
//waiting for read to complete...
doSomething(data)
file.read('file.data', function(data){
doSomethingWithData(data);
}
doOtherThingWhileReadingData();
var req = http.request(options, function (res) {
console.log('STATUS: ' + res.statusCode);
console.log('HEADERS: ' + JSON.stringify(res.headers));
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log('BODY: ' + chunk);
});
});
module.exports
to write modulesrequire('fs')
to import fs modulenpm install package_name
var http = require('http');
var server = http.createServer(function(request, response) {
response.write('Hello, world!');
response.end();
});
var port = 3500;
server.listen(port);
console.log("server listen on port: " + port);