~xje4/sapcomp

TypeScript port of SAP LZC and LZH compression
~xje4/sapcomp

New GIT repository added

1 year, 17 days ago

#sapcomp - TypeScript port of SAP LZC and LZH compression

#About

sapcomp is a greatly refactored TypeScript port of the LZC and LZH compression and decompression algorithms used by SAP in various projects. The original C/C++-code has been ported to plain TypeScript/JavaScript using only JavaScript standard/web standard APIs and types while retaining the exact compression and decompression results.

The focus of this project is to make the compression and decompression algorithms more readable. This repository is meant as reference implementation and while theoretically suitable for production, many speed-related optimizations have been removed to reduce the complexity so using this code you will get a waaaaay slower compression and decompression than with the original C code. The reduction of complexity also includes the streaming/chunking mechanism of the original code and therefore this library is only able to compress and decompress buffers and not streams.

Feel free to take this library as a base to create an optimized version in any language and if so, please tell me about it!

To be able to achieve the exactly same results, some bugs in the original code needed to be kept or replicated. Many of those bugs and other interesting behaviour is explained in NOTES. There are also some original comments left. While all comments added while refactoring are //-comments, all /**/-comments (except the license header) are original comments that have survived all stages of the refactoring.

#Compatibility

This library uses only common JavaScript-syntax and -APIs up to ES2020 and should therefore run in any modern environment like NodeJS, Deno, Bun and the browsers.

#Usage

import { compressLZC, compressLZH, decompress } from 'sapcomp/mod.ts';

const inData = new Uint8Array(/*...*/);

const lzcCompressed = compressLZC(inData);
const lzhCompressed = compressLZH(inData);

const lzcDecompressed = decompress(lzcCompressed);
const lzhDecompressed = decompress(lzhCompressed);

#License

This code is licensed under GPL-2.0-or-later.

This code is derived from the MaxDB compression code by SAP AG which is licensed under the GPL-2.0-or-later license. The code has been taken from https://gitlab.com/daberlin/sap-reposrc-decompressor/-/tree/2061b5e0e05eb974f24dff1b415d5da438b7478e.

#Contributing

This project is considered feature complete. Development is only done in terms of fixing (actual) bugs, making the code more readable and adding documentation and tests.

If you want to contribute by reporting an error or submitting a patch, please write an email or create an issue on the bugtracker of the Stark project to which this repository belongs.