0% found this document useful (0 votes)
3 views8 pages

Unit 1 NodeJS

The document provides an overview of Node.js, including its framework and library functionalities, as well as its non-blocking nature. It covers various built-in modules such as HTTP, Path, File System (fs), URL, User Defined Modules, and OS, along with code examples for each. Additionally, it explains the setup process and the creation of a simple server using Node.js.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views8 pages

Unit 1 NodeJS

The document provides an overview of Node.js, including its framework and library functionalities, as well as its non-blocking nature. It covers various built-in modules such as HTTP, Path, File System (fs), URL, User Defined Modules, and OS, along with code examples for each. Additionally, it explains the setup process and the creation of a simple server using Node.js.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Unit-1: Node JS

framework: Framework wo hota h jha hum khud ka logic likh sakte Hain kuchh set of
rules hamen follow karne padte Hain.

Library prebuilt functions hum use kr sakte h like shorting and stack data structures. If
we take example of C++ we use stl functions.

html and css browsers the engines pr chalta h.


HTML and CSS Layout Engine pr chalta H har browser ka Apna kudka Layout engine hota
Hai. for example Crome Ka layout engine blink. Firefox ka layout engine gecko and an
edge layout engine Trident. Isi trah JS Ka bhi enginr Hota Hai jise jsengine ya interpreter
kate Hai. Fastest js engine chrome Ka Hota Hai Gise V8 Kehte Hain.

Ryan Dall Ne 2009 Me browser sa interpreter alag kr tha. Or usme file handling ad kar
diya tha. use hi node js kehte h.
Non blocking

Node Setup
- npm init -y
Inbuild modules in NODEJS
http module
const http = require('http');

const server = [Link]((req, res ) => {

[Link]("Hello World from NODE JS");

[Link]();

});

[Link](3000, () => {

[Link]("Server in running");

})

Path Module
const path = require('path');

const filePath = [Link](__dirname, '[Link]');

Fs Module in NODEJS
const data = {

name: 'John Doe',

age: 30,

city: 'New York'

Promise

[Link](filePath, [Link](data)).

then(() => {
[Link]("Done");

}).catch((err) => {

[Link](err);

})

Callback

[Link](filePath, [Link](data), (err) => {

if(err) {

[Link](err);

} else {

[Link]("Done");

})

async function writeFile() {

try {

await [Link](filePath, [Link](data));

[Link]("Done");

} catch(err) {

[Link](err);

writeFile();

async function writeFile() {

try {

await [Link](filePath);
[Link]("Done");

} catch(err) {

[Link](err);

writeFile();

URL Module
const url = require('url');

const myUrl = '[Link]

const parsedUrl = [Link](myUrl, true);

[Link](parsedUrl);

User Define Module


function add(a, b) {

return a + b;

function sub(a, b) {

return a + b;

function div(a, b) {
return a + b;

function mul(a, b) {

return a + b;

// [Link] = {Addition: add, sub};

[Link] = { add, sub, div, mul };

const {add, sub} = require('./maths');

[Link](add(10, 10));

const {Addition, sub} = require('./maths');

[Link](Addition(10, 10));

OS Module
const os = require('os');

[Link]([Link]());

[Link]([Link]());

[Link]([Link]());

[Link]([Link]());

[Link]([Link]());

[Link]([Link]());

[Link]([Link]().length);

You might also like