cruise-automation / wasm-lz4 Goto Github PK
View Code? Open in Web Editor NEWhttps://github.com/lz4/lz4 compiled to WebAssembly.
Home Page: https://www.npmjs.com/package/wasm-lz4
License: Apache License 2.0
https://github.com/lz4/lz4 compiled to WebAssembly.
Home Page: https://www.npmjs.com/package/wasm-lz4
License: Apache License 2.0
For those interested, here are a few anecdotal benchmarks which suggest a slight improvement in using wasm-lz4
over lz4
bag | lz4 | wasm |
---|---|---|
129MB bag | 14.16s | 13.86s |
129MB bag | 14.72s | 13.932s |
129MB bag | 14.14s | 13.583s |
801MB bag | 1m31s | 1m26s |
801MB bag | 1m28s | 1m28s |
801MB bag | 1m28s | 1m26s |
lz4
decompress: { lz4: buffer => Buffer.from(lz4.decompress(buffer)) },
wasm-lz4
decompress: { lz4: decompress },
Hopefully, I'm not doing anything incorrectly to skew the numbers.
๐
import decompressLZ4 from "@foxglove/wasm-lz4";
async myfunction(){
...
await decompressLZ4.isLoaded;
....
}
WEBPACK is:
{
test: /\.wasm$/,
type: "javascript/auto",
use: [
{
loader: "file-loader",
options: {
name: "[name].[hash:8].[ext]",
outputPath: (url: string) => {
return path.posix.join("assets", "wasm", url);
},
publicPath: path.posix.join("assets", "wasm"),
},
},
],
},
after built, run the code, always got error:
RuntimeError: Aborted(Error: ENOENT: no such file or directory, open '..\node_modules\@foxglove\wasm-lz4\dist/wasm-lz4.wasm')
Steps to reproduce:
$ docker run -it --rm node:18 /bin/bash
# mkdir test && cd test
# npm init -y && npm i wasm-lz4
# node -e 'require("wasm-lz4")'
Result:
(node:31) ExperimentalWarning: The Fetch API is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
node:internal/deps/undici/undici:11118
Error.captureStackTrace(err, this);
^
TypeError: Failed to parse URL from /test/node_modules/wasm-lz4/wasm-lz4.wasm
at Object.fetch (node:internal/deps/undici/undici:11118:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
[cause]: TypeError [ERR_INVALID_URL]: Invalid URL
at new NodeError (node:internal/errors:393:5)
at URL.onParseError (node:internal/url:565:9)
at new URL (node:internal/url:645:5)
at new Request (node:internal/deps/undici/undici:9472:25)
at Agent.fetch2 (node:internal/deps/undici/undici:10291:25)
at Object.fetch (node:internal/deps/undici/undici:11116:28)
at fetch (node:internal/process/pre_execution:216:25)
at instantiateAsync (/test/node_modules/wasm-lz4/wasm-lz4.js:9:8977)
at createWasm (/test/node_modules/wasm-lz4/wasm-lz4.js:9:9587)
at /test/node_modules/wasm-lz4/wasm-lz4.js:9:10837 {
input: '/test/node_modules/wasm-lz4/wasm-lz4.wasm',
code: 'ERR_INVALID_URL'
}
}
Node.js v18.12.1
The same error does not occur when using Node 16.
This appears to be caused by emscripten-core/emscripten#16915, which was fixed in emscripten-core/emscripten#16917 (available in emscripten 3.1.13 and later), so it could likely be fixed by upgrading emscripten.
See also: foxglove/wasm-bz2#4
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.