Skip to content

sanjaraiy/nodejs_work

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Node.js Modules Exploration πŸš€

Welcome to the Node.js Modules Exploration repository! This repository is dedicated to understanding and implementing the core modules in Node.js, including fs, os, http, and events. Dive in and master these essential functionalities of Node.js! πŸ’»πŸ“Š

Introduction

This repository is your guide to mastering some of the most important modules in Node.js. Each module is covered with examples and explanations to help you understand their usage and applications in real-world scenarios.

Modules Covered

  • File System (fs): Learn how to work with the file system to read, write, and manipulate files.
  • Operating System (os): Get insights into the operating system-related information and methods.
  • HTTP (http): Understand how to create HTTP servers and handle requests and responses.
  • Events (events): Explore the events module to handle asynchronous events in your applications.

Installation

To get started, clone the repository and install the necessary dependencies:

git clone https://github.com/sanjaraiy/nodejs_work.git
cd nodejs_work
npm install

Usage

Each module has its own directory with detailed examples and explanations. Navigate to the desired module and run the example scripts:

cd fs
node example.js

Examples

File System (fs)

Example of reading a file:

const fs = require('fs');

fs.readFile('example.txt', 'utf8', (err, data) => {
  if (err) throw err;
  console.log(data);
});

Operating System (os)

Example of getting OS information:

const os = require('os');

console.log('Platform:', os.platform());
console.log('CPU Architecture:', os.arch());
console.log('Total Memory:', os.totalmem());

HTTP (http)

Example of creating an HTTP server:

const http = require('http');

const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello, World!\n');
});

server.listen(3000, () => {
  console.log('Server running at http://localhost:3000/');
});

Events (events)

Example of using EventEmitter:

const EventEmitter = require('events');
const eventEmitter = new EventEmitter();
eventEmitter.on('start', () => {
  console.log('Started!');
});

eventEmitter.emit('start');

Contributing

We welcome contributions! Please read our content and to get started.

Happy coding! πŸŽ‰βœ¨

About

πŸ“‚πŸš€ This repository explores the fs, os, http, and events modules in Node.js. Dive in and master these core functionalities! πŸ’»πŸ“Š

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors