Hello, and welcome to Advanced Node.js, part of the Node.js Learning Path here at Pluralsight. My name is Samer Buna, and I’m looking forward to helping you understand how the Node runtime work and learn about all the powerful built-in features that you can use in every Node process.
So if you’re ready to get started, Advanced Node.js is waiting for you. Thanks again for visiting me here at Pluralsight!
Samer Buna is a polyglot coder with years of practical experience in designing, implementing, and testing software, including web and mobile applications development, API design, functional programming, optimization, system administration, databases, and scalability. Samer worked in several industries including real estate, government, education, and publications
Concurrency Model and Event Loop One of the most important concepts to understand about Node. js is its concurrency model for handling multiple connections and the use of callbacks. You might know this as the non-blocking nature of Node. js. In Node, this model is based on an event model, just like Ruby's Event Machine, or Python's Twisted. In Node, this event model is organized through what's known as the event loop. Slow I/O operations are handled with events and callbacks so that they don't block the main single-threaded execution runtime. Everything in Node depends on this concept so it's extremely important that you fully understand it.
Node's Common Built-in Libraries Let's explore some of the common built-in modules that come with Node. Node provides a number of utilities to access information directly from the operating system. We can use the os module for that. We can read information about CPUs, like their model, speed, and times. We can read information about network interfaces. We can read their IP addresses. We can also read the mac addresses, netmasks, and families. We can read information about total and free memory, where is the OS temp directory, and most importantly, what Operating System was Node compiled for. The type method will return Linux or Windows_NT, or Darwin for OS X. We can use that method, for example, to write code specific to an Operating System. We can also read the release version of the Operating System with the release method. The userInfo method is a handy one. It returns an object with information about the current user: username, uid, gid, shell, and home directory. On Windows, the shell attribute is null and both uid and gid are -1. Os. constants return an object with all the operating system error codes and process signals. The signals list is a handy, quick way to see a reference of all process signals available in the underlying OS.