rotemdan / lzutf8.js

A high-performance Javascript string compression library
MIT License
322 stars 26 forks source link

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

Closed rotemdan closed 8 years ago

rotemdan commented 9 years ago

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" })
rotemdan commented 9 years ago

0.3.1 returned support for Buffer objects used as inputs. Output is still always Uint8Array.

rotemdan commented 9 years ago

0.3.2 adds an option for the return type to be set to "Buffer", which would convert the result to a node Buffer. The default returned type for "ByteArray" is still Uint8Array.