In this repository there is an overview of core elements of Node.js, including its built-in modules, streams, threads, and networking features. Each folder in the project demonstrates specific concepts or use cases with example code which is helpful to understand key concepts of how Node.js works.
Explore Node.js Buffer objects, which allow handling binary data efficiently.
Examples of file compression and decompression in Node.js using:
- Zlib: Standard Nodejs compression library.
- Brotli: A modern compression algorithm.
- Files: Example files for testing compression.
app.js: Demonstrates compression with Brotli.benchmark.js: Benchmarks compression performance.
Learn about the EventEmitter class in Node.js for creating and handling custom events.
Understand how to interact with the file system in Node.js for reading, writing, and managing files.
Discover how to create and manage HTTP servers and clients using the Node.js http module.
- espresso.js: Class which replaces popular Node.js framework for writing servers and routers in this example. Written using ode.js
httpmodule. - simple-web: An application where user can login and create posts. Works using
espresso.js.
Networking-related examples, including:
- Chat App: A simple real-time chat application.
- Simple TCP: Demonstrates TCP socket communication.
- Uploader App: Simple app for uploading files using Node.js.
Learn how to use streams in Node.js for handling large data efficiently. Includes examples of:
- Custom streams:
Readable,Writable, andDuplexstreams. - Practical use cases: Copying files, encrypting/decrypting data, and working with large files.
Explore multithreading in Node.js using the worker_threads module. Examples include:
- Crypto-Heavy: Handling computationally intensive tasks.
- Deadlocks: Understanding and preventing thread deadlocks.
- Heavy Server: Using threads to offload server tasks.
- Prime Generator: Generating prime numbers in worker threads.
- Race Condition: Demonstrating and resolving race conditions.
- Request Sender: Using threads for high-performance network requests.
- Shared Memory: Illustrates inter-thread communication using shared memory.
- Worker Pool: Create and manage custom pool of worker threads.
- Zlib Heavy: Compressing data using
zlibin worker threads.
- Clone the repository:
git clone https://github.com/yourusername/nodejs-fundamentals.git
- Navigate to the desired folder:
cd nodejs-fundamentals/<folder-name>
- Install dependencies (if any):
npm install
- Run the example:
node <file-name>.js
- Node.js: Install the latest LTS version from Node.js.
- npm: Comes bundled with Node.js installation.