From dc29317781e10c5536ba2f60510e4aae2ac24e82 Mon Sep 17 00:00:00 2001 From: tactonbishop Date: Thu, 21 Jul 2022 08:30:14 +0100 Subject: [PATCH] Last Sync: 2022-07-21 08:30:14 --- Programming_Languages/NodeJS/Modules/Core/events.md | 6 +++--- Programming_Languages/NodeJS/Modules/Core/fs.md | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Programming_Languages/NodeJS/Modules/Core/events.md b/Programming_Languages/NodeJS/Modules/Core/events.md index 6074f68..607a27c 100644 --- a/Programming_Languages/NodeJS/Modules/Core/events.md +++ b/Programming_Languages/NodeJS/Modules/Core/events.md @@ -6,15 +6,15 @@ tags: - node-modules --- # `events` module -In most case you won't interact with the `events` module directly since other modules and third-party modules are abstractions on top of this base-layer. For instance the `http` module is using events under the hood to handle requests and responses. +In most cases you won't interact with the `events` module directly since other modules and third-party modules are abstractions on top of it. For instance the `http` module is using events under the hood to handle requests and responses. Another way of putting this is to say that all events in Node inherit from the `EventEmitter` constructor, which is the class you instantiate to create a new event. At bottom everything in Node is an event with a callback, created via event emitters. Because Node's runtime is [event-driven](/Programming_Languages/NodeJS/Architecture/Event_loop.md), it is event-emitter cycles that are being processed by the Event Loop, although you may know them as `fs` or `http` (etc) events. The call stack that the Event Loop works through is just a series of event emissions and their associated callbacks. ## Event Emitters -* All objects that emit events are instances of the `EventEmitter` class. These objects expose an `eventEmitter.on()` function that allows one or more functions to be attached to named events emitted by the object. -* These functions are listeners of the emitter. +* All objects that emit events are instances of the `EventEmitter` class. This object exposes an `eventEmitter.on()` function that allows one or more functions to be attached to named events emitted by the object. +* These functions are **listeners** of the emitter. ## Basic syntax diff --git a/Programming_Languages/NodeJS/Modules/Core/fs.md b/Programming_Languages/NodeJS/Modules/Core/fs.md index af78b39..fa846a8 100644 --- a/Programming_Languages/NodeJS/Modules/Core/fs.md +++ b/Programming_Languages/NodeJS/Modules/Core/fs.md @@ -6,11 +6,13 @@ tags: - node-modules --- +# `fs` module + File System is an essential built-in module of Node that contains utility methods for working with files and directories. Every method associated with `fs` has a *blocking* and *asynchronous* implementation. The former obviously blocks the [event queue](Event%20queue.md), the latter does not. -The asynchronous methods are useful to have in some contexts but in general and with real-world applications, you should be using the async implementation. +The synchronous methods are useful to have in some contexts but in general and with real-world applications, you should be using the async implementation so as to accord with the single-threaded event-driven architecture of Node. ## Methods