Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ—œοΈ Run-Length Text Compressor (CodeRun Edition)

Built for the CodeRun IT Marathon. A lossless text compression tool capable of handling standard ASCII, Unicode symbols, Emojis, and Asian characters efficiently.

πŸ“– About The Project

This project is a web-based compression tool that implements a variation of the Run-Length Encoding (RLE) algorithm. Unlike basic string manipulators, our engine is designed to handle UTF-8 multi-byte characters correctly.

Most JavaScript string methods fail when splitting Emojis (surrogate pairs), but this tool uses iterator-based splitting to ensure that characters like "πŸ”₯" or "ζ–‡" are treated as single units, preventing data corruption during compression.

Key Features

πŸ“‰ Lossless Compression: Reduces file size for repetitive text sequences.

🌏 Unicode Support: Fully supports Japanese/Chinese characters and Emojis (e.g., πŸš€, 🀣).

πŸ“Š Real-Time Metrics: Calculates Compression Ratio, Input/Output byte size, and Execution time in milliseconds.

πŸ“‚ File Handling: Drag-and-drop support for .txt files.

⚑ Performance: Uses TextEncoder for accurate byte-level measurement.

βš™οΈ How It Works (The Algorithm)

The core logic resides in src/utils/compressionEngine.js.

Compression Logic

We iterate through the string and count consecutive identical characters. The output format is [Character][Count];.

Example:

Input: aaabbbcccc

Process:

Found 3 'a's

Found 3 'b's

Found 4 'c's

Output: a3;b3;c4;

The "Emoji" Challenge

In standard JavaScript, string.length returns the number of UTF-16 code units, not visual characters. An emoji like "πŸ˜€" is actually 2 code units.

Bad approach: string.split('') breaks emojis into garbage characters.

Our approach: We use the Spread Operator [...raw_text]. This utilizes the string's iterator to correctly split by Code Points, keeping emojis intact.

πŸš€ Getting Started

Follow these steps to run the project locally.

Prerequisites

Node.js installed on your machine.

npm (Node Package Manager).

Installation

Clone the repository

git clone https://github.com/SoimanVasile/coderun-compressor.git

Navigate to project folder

cd coderun-compressor

Install dependencies

npm install

Run the application

npm start

The app will open in your browser at http://localhost:3000.

πŸ“Έ Usage

Input: Type text into the left box OR drag & drop a .txt file.

Compress: Click the green Comprimă button.

Analyze: Check the "Metrici Θ™i Status" box to see how much space you saved.

Decompress: Click Decomprimă to restore the original text from the compressed output.

πŸ“‚ Project Structure

src/ β”œβ”€β”€ utils/ β”‚ └── compressionEngine.js # Core RLE Algorithm (Compress/Decompress) β”œβ”€β”€ CompressionTool.jsx # Main Application Controller β”œβ”€β”€ FileUploader.jsx # Drag & Drop Component β”œβ”€β”€ MetricsDisplay.jsx # Stats Visualization β”œβ”€β”€ App.js # Root Component └── index.js # Entry Point

πŸ‘₯ The Team

Built with πŸ’» and β˜• for CodeRun.

Soiman Vasile-Cristian - Frontend & Logic

Aerinei Ionut and Gramada Nicolae - Algorithm Optimization

About

The web server for compressing a file in js

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages