Coder Social home page Coder Social logo

lzutf8.js's Introduction

LZ-UTF8

Build Status npm version

Note: this library is significantly out-of-date and will require a full rewrite to update with recent technologies like JS modules and WebAssembly, and for better compatibility with modern frameworks like Angular and Rect.js. The design and documentation was mostly written in 2014, before any of these were relevant. Unfortunately, it is not maintained anymore, and a rewrite is unlikely to take place in the foreseeable future.

LZ-UTF8 is a string compression library and format. Is an extension to the UTF-8 character encoding, augmenting the UTF-8 bytestream with optional compression based the LZ77 algorithm. Some of its properties:

  • Compresses strings only. Doesn't support arbitrary byte sequences.
  • Strongly optimized for speed, both in the choice of algorithm and its implementation. Approximate measurements using a low-end desktops and 1MB strings: 3-14MB/s compression , 20-120MB/s decompression (detailed benchmarks and comparison to other Javascript libraries can be found in the technical paper). Due to the concentration on time efficiency, the resulting compression ratio can be significantly lower when compared to more size efficient algorithms like LZW + entropy coding.
  • Byte-level superset of UTF-8. Any valid UTF-8 bytestream is also a valid LZ-UTF8 stream (but not vice versa). This special property allows both compressed and plain UTF-8 streams to be freely concatenated and decompressed as single unit (or with any arbitrary partitioning). Some possible applications:
    • Sending static pre-compressed data followed by dynamically generated uncompressed data from a server (and possibly appending a compressed static "footer", or repeating the process several times).
    • Appending both uncompressed/compressed data to a compressed log file/journal without needing to rewrite it.
    • Joining multiple source files, where some are possibly pre-compressed, and serving them as a single concatenated file without additional processing.
  • Patent free (all relevant patents have long expired).

Javascript implementation:

  • Tested on most popular browsers and platforms: Node.js 4+, Chrome, Firefox, Opera, Edge, IE10+ (IE8 and IE9 may work with a typed array polyfill), Android 4+, Safari 5+.
  • Allows compressed data to be efficiently packed in plain Javascript UTF-16 strings (see the "BinaryString" encoding described later in this document) when binary storage is not available or desired (e.g. when using LocalStorage or older IndexedDB).
  • Can operate asynchronously, both in Node.js and in the browser. Uses web workers when available (and takes advantage of transferable objects if supported) and falls back to async iterations when not.
  • Supports Node.js streams.
  • Written in TypeScript.

Quick start

Table of Contents

API Reference

Getting started

Node.js:

npm install lzutf8
var LZUTF8 = require('lzutf8');

Browser:

<script id="lzutf8" src="https://cdn.jsdelivr.net/npm/lzutf8/build/production/lzutf8.js"></script>

or the minified version:

<script id="lzutf8" src="https://cdn.jsdelivr.net/npm/lzutf8/build/production/lzutf8.min.js"></script>

to reference a particular version use the pattern, where x.x.x should be replaced with the exact version number (e.g. 0.4.6):

<script id="lzutf8" src="https://unpkg.com/[email protected]/build/production/lzutf8.min.js"></script>

note: the id attribute and its exact value are necessary for the library to make use of web workers.

Type Identifier Strings

"ByteArray" - An array of bytes. As of 0.3.2, always a Uint8Array. In versions up to 0.2.3 the type was determined by the platform (Array for browsers that don't support typed arrays, Uint8Array for supporting browsers and Buffer for Node.js).

IE8/9 and support was dropped at 0.3.0 though these browsers can still be used with a typed array polyfill.

"Buffer" - A Node.js Buffer object.

"StorageBinaryString" - A string containing compacted binary data encoded to fit in valid UTF-16 strings. Please note the older, deprecated, "BinaryString" encoding, is still internally supported in the library but has been removed from this document. More details are included further in this document.

"Base64" - A base 64 string.

Core Methods

LZUTF8.compress(..)

var output = LZUTF8.compress(input, [options]);

Compresses the given input data.

input can be either a String or UTF-8 bytes stored in a Uint8Array or Buffer

options (optional): an object that may have any of the properties:

  • outputEncoding: "ByteArray" (default), "Buffer", "StorageBinaryString" or "Base64"

returns: compressed data encoded by encoding, or ByteArray if not specified.

LZUTF8.decompress(..)

var output = LZUTF8.decompress(input, [options]);

Decompresses the given compressed data.

input: can be either a Uint8Array, Buffer or String (where encoding scheme is then specified in inputEncoding)

options (optional): an object that may have the properties:

  • inputEncoding: "ByteArray" (default), "StorageBinaryString" or "Base64"
  • outputEncoding: "String" (default), "ByteArray" or "Buffer" to return UTF-8 bytes

returns: decompressed bytes encoded as encoding, or as String if not specified.

Asynchronous Methods

LZUTF8.compressAsync(..)

LZUTF8.compressAsync(input, [options], callback);

Asynchronously compresses the given input data.

input can be either a String, or UTF-8 bytes stored in an Uint8Array or Buffer.

options (optional): an object that may have any of the properties:

  • outputEncoding: "ByteArray" (default), "Buffer", "StorageBinaryString" or "Base64"
  • useWebWorker: true (default) would use a web worker if available. false would use iterated yielding instead.

callback: a user-defined callback function accepting a first argument containing the resulting compressed data as specified by outputEncoding (or ByteArray if not specified) and a possible second parameter containing an Error object.

On error: invokes the callback with a first argument of undefined and a second one containing the Error object.

Example:

LZUTF8.compressAsync(input, {outputEncoding: "StorageBinaryString"}, function (result, error) {
    if (error === undefined)
        console.log("Data successfully compressed and encoded to " + result.length + " characters");
    else
        console.log("Compression error: " + error.message);
});

LZUTF8.decompressAsync(..)

LZUTF8.decompressAsync(input, [options], callback);

Asynchronously decompresses the given compressed input.

input: can be either a Uint8Array, Buffer or String (where encoding is set with inputEncoding).

options (optional): an object that may have the properties:

  • inputEncoding: "ByteArray" (default), "StorageBinaryString" or "Base64"
  • outputEncoding: "String" (default), "ByteArray" or "Buffer" to return UTF-8 bytes.
  • useWebWorker: true (default) would use a web worker if available. false would use incremental yielding instead.

callback: a user-defined callback function accepting a first argument containing the resulting decompressed data as specified by outputEncoding and a possible second parameter containing an Error object.

On error: invokes the callback with a first argument of undefined and a second one containing the Error object.

Example:

LZUTF8.decompressAsync(input, {inputEncoding: "StorageBinaryString", outputEncoding: "ByteArray"}, function (result, error) {
    if (error === undefined)
        console.log("Data successfully decompressed to " + result.length + " UTF-8 bytes");
    else
        console.log("Decompression error: " + error.message);
});

General notes on async operations

Web workers are available if supported by the browser and the library's script source is referenced in the document with a script tag having id of "lzutf8" (its src attribute is then used as the source URI for the web worker). In cases where a script tag is not available (such as when the script is dynamically loaded or bundled with other scripts) the value of LZUTF8.WebWorker.scriptURI may alternatively be set before the first async method call.

Workers are optimized for various input and output encoding schemes, so only the minimal amount of work is done in the main Javascript thread. Internally, conversion to or from various encodings is performed within the worker itself, reducing delays and allowing greater parallelization. Additionally, if transferable objects are supported by the browser, binary arrays will be transferred virtually instantly to and from the worker.

Only one worker instance is spawned per page - multiple operations are processed sequentially.

In case a worker is not available (such as in Node.js, IE8, IE9, Android browser < 4.4) or desired, it will iteratively process 64KB blocks while yielding to the event loop whenever a 20ms interval has elapsed. Note: In this execution method, parallel operations are not guaranteed to complete by their initiation order.

Lower-level Methods

LZUTF8.Compressor

var compressor = new LZUTF8.Compressor();

Creates a compressor object. Can be used to incrementally compress a multi-part stream of data.

returns: a new LZUTF8.Compressor object

LZUTF8.Compressor.compressBlock(..)

var compressor = new LZUTF8.Compressor();
var compressedBlock = compressor.compressBlock(input);

Compresses the given input UTF-8 block.

input can be either a String, or UTF-8 bytes stored in a Uint8Array or Buffer

returns: compressed bytes as ByteArray

This can be used to incrementally create a single compressed stream. For example:

var compressor = new LZUTF8.Compressor();
var compressedBlock1 = compressor.compressBlock(block1);
var compressedBlock2 = compressor.compressBlock(block2);
var compressedBlock3 = compressor.compressBlock(block3);
..

LZUTF8.Decompressor

var decompressor = new LZUTF8.Decompressor();

Creates a decompressor object. Can be used to incrementally decompress a multi-part stream of data.

returns: a new LZUTF8.Decompressor object

LZUTF8.Decompressor.decompressBlock(..)

var decompressor = new LZUTF8.Decompressor();
var decompressedBlock = decompressor.decompressBlock(input);

Decompresses the given block of compressed bytes.

input can be either a Uint8Array or Buffer

returns: decompressed UTF-8 bytes as ByteArray

Remarks: will always return the longest valid UTF-8 stream of bytes possible from the given input block. Incomplete input or output byte sequences will be prepended to the next block.

Note: This can be used to incrementally decompress a single compressed stream. For example:

var decompressor = new LZUTF8.Decompressor();
var decompressedBlock1 = decompressor.decompressBlock(block1);
var decompressedBlock2 = decompressor.decompressBlock(block2);
var decompressedBlock3 = decompressor.decompressBlock(block3);
..

LZUTF8.Decompressor.decompressBlockToString(..)

var decompressor = new LZUTF8.Decompressor();
var decompressedBlockAsString = decompressor.decompressBlockToString(input);

Decompresses the given block of compressed bytes and converts the result to a String.

input can be either a Uint8Array or Buffer

returns: decompressed String

Remarks: will always return the longest valid string possible from the given input block. Incomplete input or output byte sequences will be prepended to the next block.

Node.js only methods

LZUTF8.createCompressionStream()

var compressionStream = LZUTF8.createCompressionStream();

Creates a compression stream. The stream will accept both Buffers and Strings in any encoding supported by Node.js (e.g. utf8, utf16, ucs2, base64, hex, binary etc.) and return Buffers.

example:

var sourceReadStream = fs.createReadStream(“content.txt”);
var destWriteStream = fs.createWriteStream(“content.txt.lzutf8”);
var compressionStream = LZUTF8.createCompressionStream();

sourceReadStrem.pipe(compressionStream).pipe(destWriteStream);

On error: emits an error event with the Error object as parameter.

LZUTF8.createDecompressionStream()

var decompressionStream = LZUTF8.createDecompressionStream();

Creates a decompression stream. The stream will accept and return Buffers.

On error: emits an error event with the Error object as parameter.

Character encoding methods

LZUTF8.encodeUTF8(..)

var output = LZUTF8.encodeUTF8(input);

Encodes a string to UTF-8.

input as String

returns: encoded bytes as ByteArray

LZUTF8.decodeUTF8(..)

var outputString = LZUTF8.decodeUTF8(input);

Decodes UTF-8 bytes to a String.

input as either a Uint8Array or Buffer

returns: decoded bytes as String

LZUTF8.encodeBase64(..)

var outputString = LZUTF8.encodeBase64(bytes);

Encodes bytes to a Base64 string.

input as either a Uint8Array or Buffer

returns: resulting Base64 string.

remarks: Maps every 3 consecutive input bytes to 4 output characters of the set A-Z,a-z,0-9,+,/ (a total of 64 characters). Increases stored byte size to 133.33% of original (when stored as ASCII or UTF-8) or 266% (stored as UTF-16).

LZUTF8.decodeBase64(..)

var output = LZUTF8.decodeBase64(input);

Decodes UTF-8 bytes to a String.

input as String

returns: decoded bytes as ByteArray

remarks: the decoder cannot decode concatenated base64 strings. Although it is possible to add this capability to the JS version, compatibility with other decoders (such as the Node.js decoder) prevents this feature to be added.

LZUTF8.encodeStorageBinaryString(..)

Note: the older BinaryString encoding has been deprecated due to a compatibility issue with the IE browser's LocalStorage/SessionStorage implementation. This newer version works around that issue by avoiding the 0 codepoint.

var outputString = LZUTF8.encodeStorageBinaryString(input);

Encodes binary bytes to a valid UTF-16 string.

input as either a Uint8Array or Buffer

returns: String

remarks: To comply with the UTF-16 standard, it only uses the bottom 15 bits of each character, effectively mapping every 15 input bits to a single 16 bit output character. This Increases the stored byte size to 106.66% of original.

LZUTF8.decodeStorageBinaryString(..)

Note: the older BinaryString encoding has been deprecated due to a compatibility issue with the IE browser's LocalStorage/SessionStorage implementation. This newer version works around that issue by avoiding the 0 codepoint.

var output = LZUTF8.decodeStorageBinaryString(input);

Decodes a binary string.

input as String

returns: decoded bytes as ByteArray

remarks: Multiple binary strings may be freely concatenated and decoded as a single string. This is made possible by ending every sequence with special marker (char code 32768 for an even-length sequence and 32769 for a an odd-length sequence).

Release history

  • 0.1.x: Initial release.
  • 0.2.x: Added async error handling. Added support for TextEncoder and TextDecoder when available.
  • 0.3.x: Removed support to IE8/9. Removed support for plain Array inputs. All "ByteArray" outputs are now Uint8Array objects. A separate "Buffer" encoding setting can be used to return Buffer objects.
  • 0.4.x: Major code restructuring. Removed support for versions of Node.js prior to 4.0.
  • 0.5.x: Added the "StorageBinaryString" encoding.

License

Copyright (c) 2014-2018, Rotem Dan <[email protected]>.

Source code and documentation are available under the MIT license.

lzutf8.js's People

Contributors

rotemdan avatar schmetzyannick avatar jcbdev avatar pepsivontwist avatar

Stargazers

 avatar Ivan Bovin avatar Tran Quang Tien avatar Ferdinand Prantl avatar leko avatar gnehs avatar vincenteof avatar Hoai Tong Xuan avatar  avatar Andrey avatar Boris avatar  avatar 潘登峰 avatar skuramatata avatar Igor Skochinsky avatar  avatar Kristian Korsgaard avatar Zain Ali avatar CA Manas Madrecha avatar Yu LI avatar  avatar D3lta avatar FailCake avatar Adam Rood avatar Tom Hodbod avatar sambit avatar Kate, Z avatar Zsolt Jurányi avatar Vladimir Honcharenko avatar Carlos Nunez avatar Yonggoo Noh avatar Subhajit Sahu avatar Arjun Vegda avatar Pritesh Kr Jha avatar Chao Chen avatar Liam Howell avatar  avatar 嚴肅遊戲 avatar  avatar Liberty avatar Calpa Liu avatar tacigar avatar Ilya Medvedev avatar Rashed Alam avatar Peter Pan avatar  avatar Senchabot avatar Dat Dinhquoc avatar Joshua Gross avatar Vitaly Zadorozhny avatar Zidna Fadla avatar Chris Lee avatar leeray avatar  avatar Nick avatar SeungYeon Hong avatar Rannie Peralta avatar Sopanat Suradach avatar HAKOPTAK avatar Kyle Tse avatar  avatar Tom (Tung Pham Thanh) avatar  avatar Meksi Abdennour avatar Caspian Zhao avatar Sleaf avatar Fadlul Alim avatar David M. Golembiowski avatar Parbez avatar Mohammad Ahmad avatar U.M Andrew avatar Jay Fong | 方剑成 avatar KraSer avatar Sohail Alam avatar alphaAE avatar  avatar Nikita avatar Dunkan avatar Matthew avatar M̴̧̡̡̢͎̬͖̬̠̭̱̝̩̪̝̠͎͈̪̰͕͓̼̻͎̮̜̫̬͍̱̭̠̟̖͉͈̺͙͉͒́͂̾̅̚̚͜͜͜Ę̷̡̡̧̨͎͕̟̪̰͍̬̮̥̝̖̯͕̳̳̜̭͖̯͙̜̰̤̼̠̼̪̝̐̔̍̋͜͝R̶̘̹̠̻̺̟̞̦͗̓̓̐̄̀͊̏̔͂͑̉͆͘̕͝T̴̢̨̛̩̮̖̺̱͙̳̪̠̼͐͌̇̀̓́͂̎̔͗͂̄̈́̆́̏̉̀͑͗͐̈́̋̇͌̿̅͒̓͒͒̂͋͘͝͝ avatar berstend̡̲̫̹̠̖͚͓̔̄̓̐̄͛̀͘ avatar Nick Smits avatar Thanh Dang avatar Royson avatar Zhongxiang Wang avatar  avatar Aldrich Halim avatar  avatar Anthony Burak DURSUN avatar urdeveloper avatar  avatar Marcello Novelli avatar  avatar Hamed Fathi avatar Alecyrus avatar Oscar avatar Christian Cepe avatar DuncanMacWeb avatar Bruno Caimar avatar Roy avatar

Watchers

Leon Sorokin avatar Evan Frohlich avatar James Cloos avatar Michael Anthony avatar  avatar  avatar

lzutf8.js's Issues

Typescript errors from new release

node_modules/lzutf8/build/production/lzutf8.d.ts:18:43 - error TS2503: Cannot find namespace 'stream'.

18 static createCompressionStream(): stream.Transform;
~~~~~~

node_modules/lzutf8/build/production/lzutf8.d.ts:24:45 - error TS2503: Cannot find namespace 'stream'.

24 static createDecompressionStream(): stream.Transform;
~~~~~~

node_modules/lzutf8/build/production/lzutf8.d.ts:280:41 - error TS2503: Cannot find namespace 'stream'.

280 function createCompressionStream(): stream.Transform;
~~~~~~

node_modules/lzutf8/build/production/lzutf8.d.ts:281:43 - error TS2503: Cannot find namespace 'stream'.

281 function createDecompressionStream(): stream.Transform;
~~~~~~

Async methods should invoke callback on errors

When an exception is thrown, Async methods (including Web Workers) should invoke the given callback with a first argument (representing value) of undefined and a second argument containing the Error object. Node streams should emit the error event with the relevant Error object.

Does async work with Electron apps?

I know web workers aren't natively supported for electron apps like atom (where i'm trying to use this) so i was wondering how the async call works in node applications.. forking under the hood or..?

Breaking change: All returned ByteArray values are now instances of Uint8Array

Since the release of Node 4.1 it is not possible to easily patch a Buffer to behave like a Uint8Array since Buffer is now internally derived from Uint8Array and relies on its inherited methods like subarray and set (which seems to be overridden by a function that always throws an error).

In version 0.3.0 I removed all the polyfills and all outputs that have type identifier ByteArray are now instances of Uint8Array. This is a breaking change for Node users who would need to apply new Uint8Array(inputBuffer) and new Buffer(outputUint8Array) when buffer objects are desired as inputs or outputs.

Automatic internal conversion of buffer inputs can be done and that would be added soon. Conversion of outputs to Buffer objects may be available under a different encoding identifier E.g.

LZUTF8.compress(input, { outputEncoding: "Buffer" })

Deprecation warning

(node:1) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.

Docs are wrong "StorageBinaryString" should be "BinaryString"

The npm page shows compress opts outputEncoding has option for StorageBinaryString but a look at the source code shows that you have renamed the value to "BinaryString"

If I follow the docs I get error: lzutf8.js:529 Uncaught TypeError: encodeCompressedBytes: invalid output encoding requested at Object.CompressionCommon.encodeCompressedBytes (lzutf8.js:529) at Object.compress (lzutf8.js:1514) at <anonymous>:1:21

(I'm using the demo page with console open and I'm only using the console to test commands)

the code I used ctrl+f is: https://rotemdan.github.io/lzutf8/build/production/lzutf8.js
I searched for " invalid output encoding requested"

Screenshot from 2020-09-28 21-30-49

Chance to optimize the bundle size?

It is no doubt that lzutf8 is way faster than lz-string. However, the bundle size of lzutf8 is ~80KB, compared to lz-string is just ~5KB.

Would you consider to optimize the bundle size, esp., readable-stream contributes ~40% of bundle size.

Nodejs env with jsdom

In a test environement we need a fake window object for some other modules.
LZUTF8 breaks when it detacts node and a browser environement.

Saving binary string in sessionStorage in IE produces and Error

The BinaryString encoding may produce string containing 0-coded character, namely "\0". IE will throw an error when we try to save the string directly in to sessionStorage.

var str = String.fromCharCode(0);
/* Error thrown in following line */
sessionStorage.setItem('test', str);

I ran a simple test against IE sessionStorage, and find out only char with code 0 will result in an exception.

Typescript declarations (2)

Hello
File '<...>/node_modules/lzutf8/build/production/lzutf8.d.ts' is not a module.
Adding
export = LZUTF8
to declaration file fixes this issue.

Browser addon (web extension API) storage

Hi @rotemdan ! Thank you for this useful library! It works awesome !

You mentioned different browsers and localStorage, but not browser addons made with web extension API.
I'm using LZUTF8 in my browser addon storage.sync, which limits 128k bytes.

I tried different output and found {outputEncoding: "StorageBinaryString"} is the best for browser addon storage.sync

Then I face a problem:

Y1 = LZUTF8.compress(input-data, {outputEncoding: "StorageBinaryString"});

Storing the compressed data Y (string) into Firefox (78) and Chromium (90), the space it occupies in storage.sync different:

  • in Firefox: Bytes used = Y.length.
  • in Chromium: Bytes used = about 2-3 times larger than Y.length. WHY?

(The space used can be seen by storage.sync.getBytesInUse(). Both Firefox and Chromium have limitation of same quata: 128k bytes)

(Also asked here)

Could you find a explaination?

Standalone CLI implementation?

For the purposes of CI/CD, it would be helpful to have a command-line tool that could encode and decode text via piping, similar to base64.

echo PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0i\
     VVRGLTgiPz4KPHRlc3RzdWl0ZSDFCj0iMyIgZmFp\
     bHVyZXM9IjEiIHRpbWU9IjAuMDE2MDEwNiI+CiAg\
     ICDFOGNhc2UgbmHEIGhhcyBodG1sIiBjbGFzc8YV\
     SFRNTMtBMDA3Ncc/xUNlcnJvciBtZXNzYWdlPSI8\
     Yj5CT088L2I+IiB0eXDEEmk+QVJHSDwvaT7LOCZs\
     dDtpJmd0O0FSR0fEDS/FDsQKYsQJQk9PxRbFDSA8\
     L8Vnxj88L+gAtz4KxgzlAPs+\
| base64 --decode \
| lzutf8 --decode           # which doesn't currently exist

How would I create such a tool?

overwrites global variable: i

I noticed lzutf8.js overwrites my global variable: i.
I tested this by trying to declare a const i and got the error:

lzutf8..js:1 Uncaught SyntaxError: Identifier 'i' has already been declared
    at lzutf8.js:1

I see you placed everything in IIFEs which seems safe enough but maybe 'i' is hoisted somewhere?

RunningInNodeJS condition

Build 0.3.3 broke the condition.

0.3.2 was

LZUTF8.runningInNodeJS = runningInNodeJS;
if (typeof module === "object" && typeof module.exports === "object") {
  module.exports = LZUTF8;
}

0.3.3

if (runningInNodeJS()) {
  module.exports = LZUTF8;
}

Now I cannot use it in webpack build and I am forced to use v0.3.2.
Hope it can be fixed.

Thanks for the great library anyway! 👍

vs lz-string

Just did a comparison between lzutf8 and lz-string using:

https://rotemdan.github.io/lzutf8/demo/
http://pieroxy.net/blog/pages/lz-string/demo.html

Using the input

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

I get:

time size
raw - 574 bytes
lzutf8 2.8ms 466 bytes
lz-string 1 ms 196 bytes

default export?

Can you build with a Types declaration flag?

Could not find a declaration file for module 'lzwcompress'. 'c:/development/Ground
Zero/functions/node_modules/lzwcompress/lzwCompress.js' implicitly has an 'any' type.
Try npm i --save-dev @types/lzwcompress if it exists or add a new declaration (.d.ts) file containing declare module 'lzwcompress';

Reference examples of before/after compression?

I've made a good amount of progress porting this compression algorithm to Ruby. However, only most of my test cases work -- not all of them. I'm borrowing some from the xunit-viewer NPM project, in which a compressed & b64-encoded string is used.

I'm running into sporadic errors in my implementation where the distance in a sized pointer sequence is greater than the length of the output string. Since this repo doesn't include hard copies of expected compressed data, I'm not sure how to troubleshoot.

Can you reply with a set of inputs and outputs, b64-encoded for absolute certainty of their contents? That would be a huge help.

Compatible with gzip?

Are the compressed strings compatible with gzip? That would make interop easily so that the raw data could be worked with using external tools.

react-native missing dependencies

I was trying to use this lib in react native and got this error:

Unable to resolve module events from node_modules\readable-stream\lib_stream_readable.js: events could not be found within the project or in these directories:
node_modules

to fix need install this 2 dependencies to work in react native
readable-stream
events

Node.js v5.5.0 "Range Error: Maxium call stack size exceeded"

It ran fine on Node.js 0.12 but on version 5.5.0 I get the following infinite stack dump...
RangeError: Maximum call stack size exceeded
at Buffer.genericArraySubarrayFunctionPolyfill as subarray
at Buffer.slice (buffer.js:635:23)
at Buffer.genericArraySubarrayFunctionPolyfill as subarray
at Buffer.slice (buffer.js:635:23)
at Buffer.genericArraySubarrayFunctionPolyfill as subarray
at Buffer.slice (buffer.js:635:23)

builds are missing

the development- and production-builds are missing, therefore the unpkg-links are broken:

<script id="lzutf8" src="https://unpkg.com/lzutf8/production/lzutf8.min.js"></script>

temporary workaround

<script id="lzutf8" src="https://rotemdan.github.io/lzutf8/build/production/lzutf8.js"</script>

Add support for options flag --timer which calculates time it takes to perform async compression and decompression

Hello, we have been using this lib to compress and decompress larger strings. For our use case we are using compressAsync function, and sync decompression. We want to run load test on our page and are interested in calculating the time the lib takes to perform async compression and decompression.

Can you please add an options flag to the async compression and decompression function which set to true, calculates the time it takes to compress/ decompress a string and we can read the timer value in the callback function?

Something like this:
LZUTF8.compressAsync(input, {timer: true}, function (result, error, timer) { if (error === undefined && timer === undefined) { console.log("Data successfully compressed and encoded to " + result.length + " characters" + in "**timer**" ms); } });

Nothing in release history for the most recent 0.6.0 version

I noticed that the packages was updated but nothing is mentioned in the release history, so I am not sure what changes from 0.5.5 to 0.6.0. It would be helpful to know what's going before updating a project with the newer version of this package.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.