Crates.io | brotli-dec-wasm |
lib.rs | brotli-dec-wasm |
version | 2.3.0 |
source | src |
created_at | 2023-07-13 03:55:03.683453 |
updated_at | 2024-04-19 04:27:49.779185 |
description | Brotli decompressor for browsers and web workers with WASM, which still has a small size (about 300KB) |
homepage | https://github.com/ustclug-dev/brotli-dec-wasm |
repository | https://github.com/ustclug-dev/brotli-dec-wasm.git |
max_upload_size | |
id | 915039 |
size | 81,242 |
Brotli decompressor for browsers and web workers with WASM, which still has a small size (about 300KB 200KB)
If you are looking for a compressor, see Alternatives
Starting from v2.0.0, this package can be used as an exact drop-in replacement of brotli-wasm.
You can simply switch between import brotli from 'brotli-wasm'
and import brotli from 'brotli-dec-wasm'
.
More detailed usage can be found in brotli-wasm Usage section.
Examples are also available in the unit tests in brotli-wasm:test/brotli.spec.ts and example projects in brotli-wasm:example.
Especially, a TransformStream
example is available in brotli-wasm:example/web-next-transformstream/app/utils.ts.
Additionally, we export the JS API generated by wasm-pack and the WASM binary file.
They may be useful for cases where you need to instantiate the WASM module with a URL.
Check *.asset.*
files in example/webpack
for examples.
BREAKING CHANGE: Since webpack 5 WebAssembly is not enabled by default and flagged as experimental feature. You need to enable one of the WebAssembly experiments via 'experiments.asyncWebAssembly: true' (based on async modules) or 'experiments.syncWebAssembly: true' (like webpack 4, deprecated).
Set experiments.syncWebAssembly: true
for old code, experiments.asyncWebAssembly: true
for new code.
The code is quite simple, which is just a wrapper of the crate brotli-decompressor (other than crate brotli, though brotli depends on brotli-decompressor)
Build configuration such as opt-level = "s"
, are fine-tuned with manual tests, to make the bundle as small as possible
The package is at least used by myself in my blog mylmoe, which provides a page to (de)compress Brotli online
More alternatives are available in brotli-wasm Alternatives section
One surprising thing is, in js
folder of the offical google/brotli repository, there is a pure JavaScript decompressor implementation, which is even a little smaller than this package in size. However, it is not published on NPM. I do not know the reason and since that, I do not suggest using it.
At least >= v1.3.3
Copyright (C) myl7
SPDX-License-Identifier: MIT OR Apache-2.0