Node_js
Node_js
js
This allows Node.js to handle thousands of concurrent connections with a single server without
introducing the burden of managing thread concurrency, which could be a significant source of bugs.
Node.js has a unique advantage because millions of frontend developers that write JavaScript for
the browser are now able to write the server-side code in addition to the client-side code without the need
to learn a completely different language.
In Node.js the new ECMAScript standards can be used without problems, as you don't have to
wait for all your users to update their browsers - you are in charge of deciding which ECMAScript version
to use by changing the Node.js version, and you can also enable specific experimental features by running
Node.js with flags.
Node.js
Features of Node.js
Asynchronous and Event Driven − All APIs of Node.js library are asynchronous,
that is, non-blocking. It essentially means a Node.js based server never waits for
an API to return data. The server moves to the next API after calling it and a
notification mechanism of Events of Node.js helps the server to get a response from
the previous API call.
Very Fast − Being built on Google Chrome's V8 JavaScript Engine, Node.js library
is very fast in code execution.
Node.js
Node.js relies on various dependencies under the hood for providing various features.
• V8
• libuv
• llhttp
• c-ares
• OpenSSL
Node.js
Figure 1.2 is a high-level overview of Node’s internals that shows how everything fits into place.
Node’s core modules are mostly written in JavaScript. That means if there’s anything you either don’t
understand or want to understand in more detail, then you can read Node’s source code. This includes
features like networking, high-level file system operations, the module system, and streams. It also
includes Node-specific features like running multiple Node processes at once with the cluster module, and
wrapping sections of code in event-based error handlers, known as domains.
The next few sections focus on each core module in more detail, starting with the
events API.
Node.js
Node.js
• Event Emitter :
Node.js uses events module to create and handle custom events. The EventEmitter class can be
used to create and handle custom events module.
• Streams :
Streams are one of the fundamental concepts of Node.js. Streams are a type of data-handling
methods and are used to read or write input into output sequentially. Streams are used to handle
reading/writing files or exchanging information in an efficient way.
The official Node.js documentation defines streams as “A stream is an abstract interface for working with
streaming data in Node.js.” The stream module provides an API for implementing the stream interface.
Examples of the stream object in Node.js can be a request to an HTTP server and process.stdout are both
stream instances. In short, Streams are objects in Node.js that lets the user read data from a source or write
data to a destination in a continuous manner.
Node.js
• FS (File System):
To handle file operations like creating, reading, deleting, etc., Node.js provides an inbuilt module
called FS (File System). Node.js gives the functionality of file I/O by providing wrappers around the
standard POSIX functions. All file system operations can have synchronous and asynchronous forms
depending upon user requirements. To use this File System module, use the require() method.
• HTTP Module:
To make HTTP requests in Node.js, there is a built-in module HTTP in Node.js to transfer data
over the HTTP. To use the HTTP server in the node, we need to require the HTTP module. The HTTP
module creates an HTTP server that listens to server ports and gives a response back to the client.
• NET:
Node.js Net module allows you to create TCP or IPC servers and clients. A TCP client initiates a
connection request to a TCP server to establish a connection with the server.
Node.js
INSTALLATION
Node.js
Node.js
Node.js