Wrapping Up
In this chapter we’ve used Node to perform file operations in Node’s evented, asynchronous, callback-oriented way. You learned how to watch files for changes, and read and write files. You also learned how to spawn child processes and access command-line arguments.
Along the way, we covered the EventEmitter class. We used the on() method to listen for events and handle them in our callback functions. And we used Streams—which are a special kind of EventEmitter—to process data in buffered chunks or pipe it directly to other streams.
Oh, and let’s not forget about errors. You learned Node’s convention of passing an err argument to callbacks, and how error events can be captured from an EventEmitter.
Keep these patterns in mind as you ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access