als-compress-json
v1.0.0
Published
A utility library for compressing JSON data by identifying and compacting repeated string patterns
Downloads
1
Maintainers
Readme
Compress JSON
A utility library for compressing JSON data by identifying and compacting repeated string patterns.
Installation
To install this package, run the following command:
npm install compress-json
Usage
Here's a basic usage of this library:
const CompressValues = require('compress-json');
const data = {
// your data here...
};
const { dictionary, compressed } = CompressValues.compress(data);
const decompressed = CompressValues.decompress({ dictionary, compressed });
API
The library exports two static methods:
compress(data: object, length?: number, prefix?: string): CompressedData
- Compresses the given JSON data.
length
andprefix
are optional parameters to adjust the compression settings.
- Compresses the given JSON data.
decompress(data: CompressedData, length?: number, prefix?: string): object
- Decompresses data previously compressed by the
compress
method.length
andprefix
should match the values used when compressing.
- Decompresses data previously compressed by the
The CompressedData
type is an object with the following structure:
{
dictionary: string[],
dictionaryString: string,
compressed: string, // stringified json
savedBytes: number,
workTime: number,
}