Node is also huge on streams and streaming. You can think of streams like arrays
but instead of having data distributed over space, streams can be thought of as data
distributed over time. By bringing data in chunk by chunk, the developer is given
the ability to handle that data as it comes in instead of waiting for it all to arrive
before acting. Here's how we would stream resource.json:引自 Streaming Data
var stream = fs.createReadStream('./resource.json')
stream.on('data', function (chunk) {
console.log(chunk)
})
stream.on('end', function () {
console.log('finished')
})