From 4a51713805473d4677e075afec5c8ebe7920a645 Mon Sep 17 00:00:00 2001 From: Colin Barndt Date: Fri, 5 Feb 2021 20:45:34 +0100 Subject: [PATCH 1/3] Delete package.json This file will now be generated by wasm-pack automatically. --- pkg/package.json | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 pkg/package.json diff --git a/pkg/package.json b/pkg/package.json deleted file mode 100644 index 4d4dd80..0000000 --- a/pkg/package.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "name": "wasm-gzip", - "version": "0.1.3", - "description": "Compress data on the web using Webassembly and Rust.", - "main": "wasm_gzip.js", - "directories": { - "test": "tests" - }, - "files": [ - "tests", - "README.md", - "wasm_gzip_bg.js", - "wasm_gzip_bg.wasm", - "wasm_gzip_bg.wasm.d.ts", - "wasm_gzip.d.ts", - "wasm_gzip.js" - ], - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "keywords": [ - "wasm", - "gzip", - "compression" - ], - "author": "Colin Tim Barndt", - "license": "Apache-2.0", - "repository": "github:ColinTimBarndt/wasm-gzip" -} From d1b339e190c80eca198393456add0d6470f40414 Mon Sep 17 00:00:00 2001 From: Colin Barndt Date: Fri, 5 Feb 2021 20:45:59 +0100 Subject: [PATCH 2/3] Delete README.md This file will now be generated by wasm-pack automatically. --- pkg/README.md | 81 --------------------------------------------------- 1 file changed, 81 deletions(-) delete mode 100644 pkg/README.md diff --git a/pkg/README.md b/pkg/README.md deleted file mode 100644 index 18181be..0000000 --- a/pkg/README.md +++ /dev/null @@ -1,81 +0,0 @@ -# Wasm-Gzip - -Wasm-Gzip was built for the web and does not work with NodeJS. - -This small library allows compression and decompression with Gzip -using the [libflate](https://crates.io/crates/libflate) Rust library. -It also comes with functions to convert a string into UTF-8 bytes and -back. The binary WASM is very lightweight (~125 KiB) which may be useful -to compress network traffic or for web applications that let a user save -and load files. - -You can see the Rust source code on [GitHub](https://github.com/ColinTimBarndt/wasm-gzip). - -## Examples - -### Compress binary data - -In this example, binary data in a Uint8Array is compressed and decompressed. - -```js -import init, { compressGzip, decompressGzip } from "./wasm_gzip.js"; - -let inputData = new Uint8Array([ - 0x0a, - 0x83, - 0xd8, - 0x4a, - 0x84, - 0x0d, - 0x44, - 0x02, - 0xbb, - 0x1f, - 0xcd, - 0x33, - 0x24, - 0x8e, - 0x49, - 0x99, -]); - -// Load the WASM -init().then(() => { - let compressed = compressGzip(inputData); - console.log(compressed); - - // If decompressing fails, undefined is returned. - let decompressed = decompressGzip(compressed); - console.log(decompressed, inputData); -}); -``` - -### Compress text - -```js -import init, { compressStringGzip, decompressStringGzip } from "./wasm_gzip.js"; - -let text = `\ -Exercitationem placeat consequatur cumque sint qui et tenetur. Quaerat vel ratione -vitae a perspiciatis consectetur numquam. Dicta illo ducimus explicabo molestiae -assumenda. Quisquam reiciendis aspernatur in ullam. Quia magnam in itaque quaerat -quisquam ipsa voluptatem. -`.repeat(10); - -// Load the WASM -init().then(() => { - let compressed = compressStringGzip(text); - console.log(text.length, compressed.length); - - // If decompressing fails, undefined is returned. - let reverse = decompressStringGzip(compressed); - console.log(reverse == text); -}); -``` - -## Tests - -The functionality of this package was tested using the `.\tests\browser.js` test script. -It has to be executed in the browser via the HTML file to work properly. Compression and -decompression were tested with "normal" text data and randomized UTF-8 and binary data -with a size of up to 183 KB. Empty input (empty Strings or Arrays) do not produce an error. From 029c677ebbcfd1f5b10c4711c09d804700a24127 Mon Sep 17 00:00:00 2001 From: Colin Barndt Date: Fri, 5 Feb 2021 20:47:09 +0100 Subject: [PATCH 3/3] Delete .gitignore This file will no longer be generated by the build script. --- pkg/.gitignore | 1 - 1 file changed, 1 deletion(-) delete mode 100644 pkg/.gitignore diff --git a/pkg/.gitignore b/pkg/.gitignore deleted file mode 100644 index d26296c..0000000 --- a/pkg/.gitignore +++ /dev/null @@ -1 +0,0 @@ -wasm_* \ No newline at end of file