Skip to content

Commit

Permalink
Heatshrink docs, fix #2014
Browse files Browse the repository at this point in the history
  • Loading branch information
gfwilliams committed Aug 16, 2023
1 parent ca68d68 commit 6a83202
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions libs/compression/jswrap_heatshrink.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ Functions here take and return buffers of data. There is no support for
streaming, so both the compressed and decompressed data must be able to fit in
memory at the same time.
```
var c = require("heatshrink").compress("Hello World");
// =new Uint8Array([....]).buffer
var d = require("heatshrink").decompress(c);
// =new Uint8Array([72, 101, ...]).buffer
E.toString(d)
// ="Hello World"
```
If you'd like a way to perform compression/decompression on desktop, check out https://github.com/espruino/EspruinoWebTools#heatshrinkjs
*/
Expand All @@ -54,7 +63,11 @@ If you'd like a way to perform compression/decompression on desktop, check out h
"return_object" : "ArrayBuffer",
"ifndef" : "SAVE_ON_FLASH"
}
Compress the heatshrink-encoded data supplied as input.
Compress the data supplied as input, and return heatshrink encoded data as an ArrayBuffer.
No type information is stored, and the `data` argument is treated as an array of bytes
(whether it is a `String`/`Uint8Array` or even `Uint16Array`), so the result of
decompressing any compressed data will always be an ArrayBuffer.
If you'd like a way to perform compression/decompression on desktop, check out https://github.com/espruino/EspruinoWebTools#heatshrinkjs
*/
Expand Down Expand Up @@ -96,11 +109,13 @@ JsVar *jswrap_heatshrink_compress(JsVar *data) {
"params" : [
["data","JsVar","The data to decompress"]
],
"return" : ["JsVar","Returns the result as an ArrayBuffer"],
"return" : ["JsVar","Returns the result as an `ArrayBuffer`"],
"return_object" : "ArrayBuffer",
"ifndef" : "SAVE_ON_FLASH"
}
Decompress the heatshrink-encoded data supplied as input.
Decompress the heatshrink-encoded data supplied as input, and return it as an `ArrayBuffer`.
To get the result as a String, wrap `require("heatshrink").decompress` in `E.toString`: `E.toString(require("heatshrink").decompress(...))`
If you'd like a way to perform compression/decompression on desktop, check out https://github.com/espruino/EspruinoWebTools#heatshrinkjs
*/
Expand Down

0 comments on commit 6a83202

Please sign in to comment.