npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@zenithcore/ost-compression

v1.5.0

Published

Okaily-Srivastava-Tbakhi (OST) encoding algorithm for textual data compression, optimized for JavaScript/TypeScript and ZenithKernel bundles

Downloads

24

Readme

@zenithcore/ost-compression

Okaily-Srivastava-Tbakhi (OST) Encoding Algorithm for textual data compression, specifically optimized for JavaScript/TypeScript source code and ZenithKernel bundles.

🎓 About the Algorithm

The OST encoding algorithm is named after its researchers:

  • Anas Al-okaily (King Hussein Cancer Center, Jordan)
  • Pramod Srivastava
  • Abdelghani Tbakhi (King Hussein Cancer Center, Jordan)

Based on the research paper: "A Novel Encoding Algorithm for Textual Data Compression"

🌟 Features

🧬 Advanced Pattern Recognition

  • Adaptive dictionary building with sliding window approach
  • Context-aware pattern extraction
  • Frequency-based pattern optimization

⚡ JavaScript/TypeScript Optimization

  • Syntax-aware preprocessing
  • Keyword compression using Unicode symbols
  • Operator optimization for common patterns

📊 Superior Compression

  • Outperforms traditional algorithms on structured text
  • Optimized for programming languages
  • Lossless compression with exact restoration

🔧 Configurable Parameters

  • Adjustable window sizes and pattern lengths
  • Dictionary size optimization
  • Syntax optimization toggles

🚀 Installation

npm install @zenithcore/ost-compression

📖 Usage

Basic Compression

import { compress, decompress } from '@zenithcore/ost-compression';

const sourceCode = `
function fibonacci(n) {
  if (n <= 1) return n;
  return fibonacci(n - 1) + fibonacci(n - 2);
}
`;

// Compress
const result = await compress(sourceCode, {
  method: 'huffman',
  labelLength: 3,
  windowLength: 512,
  enableOptimizations: true
});

console.log('Compression ratio:', result.ratio + 'x');
console.log('Original size:', sourceCode.length);
console.log('Compressed size:', result.compressed.length);

// Decompress
const restored = await decompress(result.compressed, result.metadata);
console.log('Restored:', restored === sourceCode); // true

Advanced Usage with OST Encoder

import { OSTEncoder, OSTDecoder } from '@zenithcore/ost-compression';

const encoder = new OSTEncoder({
  windowSize: 1024,
  labelLength: 4,
  minPatternLength: 3,
  maxPatternLength: 64,
  dictionarySize: 8192,
  enableSyntaxOptimization: true
});

// Encode
const encoded = await encoder.encode(sourceCode);
console.log('Dictionary patterns:', encoded.dictionary.size);
console.log('Compression ratio:', encoded.metadata.compressionRatio);

// Decode
const decoder = new OSTDecoder();
const decoded = await decoder.decode(encoded);
console.log('Successfully restored:', decoded.length, 'characters');

Configuration Options

interface OSTConfig {
  windowSize: number;           // Sliding window size (default: 512)
  labelLength: number;          // Pattern label length (default: 3)
  minPatternLength: number;     // Minimum pattern length (default: 2)
  maxPatternLength: number;     // Maximum pattern length (default: 32)
  dictionarySize: number;       // Maximum dictionary size (default: 4096)
  enableSyntaxOptimization: boolean; // Enable JS/TS optimizations (default: true)
}

🔬 Algorithm Details

Pattern Extraction

The OST algorithm uses a sliding window approach to extract recurring patterns:

  1. Window Scanning: Slides through text with configurable window size
  2. Pattern Frequency: Counts occurrence of all possible substrings
  3. Benefit Calculation: Ranks patterns by frequency × length
  4. Dictionary Building: Selects top patterns for compression dictionary

Syntax Optimization

For JavaScript/TypeScript code, OST applies preprocessing:

  • functionƒ (Unicode function symbol)
  • => (Arrow symbol)
  • const (Complex numbers symbol)
  • === (Identical to symbol)
  • And many more optimizations...

Encoding Process

  1. Preprocessing: Apply syntax optimizations
  2. Dictionary Building: Extract and rank patterns
  3. Encoding: Replace patterns with dictionary references
  4. Output: Compressed data + dictionary + metadata

📊 Performance

Compression Ratios (typical)

  • JavaScript/TypeScript: 3-8x compression
  • JSON data: 4-12x compression
  • HTML/XML: 5-15x compression
  • General text: 2-6x compression

Benchmarks

Source Type          | Size (KB) | Compressed (KB) | Ratio | Time (ms)
---------------------|-----------|-----------------|-------|----------
React Component      | 45.2      | 8.1            | 5.6x  | 12
TypeScript Module   | 128.7     | 18.3           | 7.0x  | 28
JSON Configuration  | 67.4      | 5.2            | 13.0x | 8

🧪 Testing

# Run tests
bun test

# Run benchmarks
bun run benchmark

# Type checking
bun run typecheck

🔬 Research & Citations

If you use this implementation in academic work, please cite:

@article{okaily2023ost,
  title={A Novel Encoding Algorithm for Textual Data Compression},
  author={Al-okaily, Anas and Srivastava, Pramod and Tbakhi, Abdelghani},
  journal={[Journal Name]},
  year={2023},
  publisher={[Publisher]}
}

🤝 Contributing

Contributions are welcome! Please read our contributing guidelines and submit pull requests.

📄 License

MIT License - see the LICENSE file for details.


Part of the ZenithKernel ecosystem 🌊

Implementing cutting-edge compression research for modern web development