Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/satyam-2001/data-compression
https://github.com/satyam-2001/data-compression
Last synced: 14 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/satyam-2001/data-compression
- Owner: Satyam-2001
- Created: 2023-12-30T13:11:01.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-12-30T15:04:20.000Z (about 1 year ago)
- Last Synced: 2025-01-09T09:38:34.497Z (19 days ago)
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Data Compression
The `data compression` npm package provides a lightweight solution for compressing data using Huffman encoding and converting it into a URI-friendly string format. This makes it convenient for transferring data over URIs while minimizing the payload size. The package exposes two main methods, `encode` and `decode`, allowing users to efficiently compress and decompress data.
**Features:**
- **Huffman Encoding:** Utilizes Huffman coding, a widely used compression algorithm, to efficiently encode data.
- **URI-friendly:** Converts the compressed data into a URI-friendly string format, ensuring compatibility with URIs and minimizing transfer size.- **Easy Integration:** Simple and straightforward API with two key methods, `encode` for compression and `decode` for decompression.
# Install
```bash
npm install data-compression
```Enhance your data transfer efficiency with the `data-compression` npm package by seamlessly integrating Huffman encoding and URI-friendly serialization into your projects.
# Example Usage
```javascript
import { encode, decode } from 'data-compression'// Sample data
const dataToEncode = {
tile: 'dataToEncode',
data: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. ' +
'Lorem ipsum dolor sit amet, consectetur adipiscing elit' +
'Lorem ipsum dolor sit amet, consectetur adipiscing elit' +
'Lorem ipsum dolor sit amet, consectetur adipiscing elit',
};// Encode data
const { encodedData, compression_ratio, binaryEnocded } = encode(dataToEncode);// Decode data
const decodedData = decode(encodedData);console.log('Compression Ratio', compression_ratio)
console.log('Binary Encoded Data', binaryEnocded)
console.log('Original Data:', dataToEncode);
console.log('Encoded Data:', encodedData);
console.log('Decoded Data:', decodedData);
```