0% found this document useful (0 votes)
2 views15 pages

Node_js

Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
Download as pptx, pdf, or txt
0% found this document useful (0 votes)
2 views15 pages

Node_js

Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1/ 15

Node.

js

Node.js is an open-source and cross-platform JavaScript runtime environment. It is a popular tool


for almost any kind of project!
Node.js runs the V8 JavaScript engine, the core of Google Chrome, outside of the browser. This allows
Node.js to be very performant.
A Node.js app runs in a single process, without creating a new thread for every request. Node.js
provides a set of asynchronous I/O primitives in its standard library that prevent JavaScript code from
blocking and generally, libraries in Node.js are written using non-blocking paradigms, making blocking
behavior the exception rather than the norm.
When Node.js performs an I/O operation, like reading from the network, accessing a database or
the filesystem, instead of blocking the thread and wasting CPU cycles waiting, Node.js will resume the
operations when the response comes back.
Node.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

Node.js = Runtime Environment + JavaScript Library


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

Single Threaded but Highly Scalable


Node.js uses a single threaded model with event looping. Event mechanism helps the server to
respond in a non-blocking way and makes the server highly scalable as opposed to traditional servers
which create limited threads to handle requests. Node.js uses a single threaded program and the same
program can provide service to a much larger number of requests than traditional servers like Apache
HTTP Server.
No Buffering
Node.js applications never buffer any data. These applications simply output the data in chunks.
License
Node.js is released under the MIT license(Massachusetts Institute of Technology).
Node.js

Main Features of Node.js


Node’s main features are its standard library, module system, and npm. we’ll focus on teaching
you how to use these parts of Node. We’ll use third-party libraries where it’s considered best practice, but
you’ll see a lot of Node’s built-in features.
In fact, Node’s strongest and most powerful feature is its standard library. This is really two parts:
a set of binary libraries and the core modules. The binary libraries include libuv, which provides a fast run
loop and non-blocking I/O for networking and the file system. It also has an HTTP library, so you can be
sure your HTTP clients and servers are fast.
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

You might also like