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 ...
Get Node.js the Right Way now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.