
Security News
libxml2 Maintainer Ends Embargoed Vulnerability Reports, Citing Unsustainable Burden
Libxml2’s solo maintainer drops embargoed security fixes, highlighting the burden on unpaid volunteers who keep critical open source software secure.
@bokuweb/zstd-wasm
Advanced tools
<img src="https://img.shields.io/npm/v/@bokuweb/zstd-wasm.svg" alt="Build Status"
Zstandard for browser, Node.js and Deno. For now support only simple API.
npm install @bokuweb/zstd-wasm
Playground: https://runkit.com/bokuweb/60f1172a58aae5001aea2418
const { init, compress, decompress } = require('@bokuweb/zstd-wasm');
(async () => {
await init();
const compressed = compress(Buffer.from('Hello zstd!!'), 10);
const res = decompress(compressed);
Buffer.from(res).toString(); // Hello zstd!!
})();
See also, https://github.com/bokuweb/zstd-wasm/tree/master/examples/deno
import { init, decompress, compress } from 'https://deno.land/x/zstd_wasm/deno/zstd.ts';
await init();
const encoder = new TextEncoder();
const buffer = encoder.encode('Hello World');
const compressed = compress(buffer, 10);
const decompressed = decompress(compressed);
const decoder = new TextDecoder();
console.log(decoder.decode(decompressed));
import { init, compress, decompress } from '@bokuweb/zstd-wasm';
(async () => {
await init('./zstd.wasm'); // Please deploy `node_modules/@bokuweb/zstd-wasm/lib/wasm/zstd.wasm` to your hosting server.
const compressed = compress(Buffer.from('Hello zstd!!'), 10);
const res = decompress(compressed);
Buffer.from(res).toString(); // Hello zstd!!
})();
vite
Please set following config in vite.config.js
.
import { defineConfig } from 'vite';
export default defineConfig({
optimizeDeps: {
exclude: ['@bokuweb/zstd-wasm'],
esbuildOptions: {
target: 'es2020',
},
},
});
We need to use file-loader
with webpack4.
This is because, webpack doesn’t work well with wasm modules created with Emscripten.
See, https://github.com/webpack/webpack/issues/7352
import { init, compress, decompress } from '@bokuweb/zstd-wasm';
(async () => {
await init();
const compressed = compress(Buffer.from('Hello zstd!!'), 10);
const res = decompress(compressed);
Buffer.from(res).toString(); // Hello zstd!!
})();
In this case, please install file-loader
by yourself.
{
// ...snipped
module: {
rules: [
{
test: /zstd\.wasm$/,
type: 'javascript/auto',
loader: 'file-loader', // Please use file loader
},
],
},
}
We need to use Asset Modules
with webpack5.
This is because, webpack doesn’t work well with wasm modules created with Emscripten.
See, https://github.com/webpack/webpack/issues/7352
import { init, compress, decompress } from '@bokuweb/zstd-wasm';
(async () => {
await init();
const compressed = compress(Buffer.from('Hello zstd!!'), 10);
const res = decompress(compressed);
Buffer.from(res).toString(); // Hello zstd!!
})();
{
// ...snipped
module: {
rules: [
{
test: /zstd\.wasm/,
type: 'asset/resource',
},
],
},
// ...snipped
}
zstd --train FullPathToTrainingSet/* -o dictionaryName
const dict = readFileSync('./dict');
const compressed = compressUsingDict(createCCtx(), buffer, dict, 10);
const dict = readFileSync('./dict');
const decompressed = decompressUsingDict(createDCtx(), buffer, dict);
See also example
Initialize module.
Please specify path to zstd.wasm
without bunders on browser.
Example:
const compressed = compress(buffer, 10);
Example:
const decompressed = decompress(buffer);
createCCtx
.Example:
const dict = readFileSync('./dict');
const compressed = compressUsingDict(createCCtx(), buffer, dict, 10);
createDCtx
.Example:
const dict = readFileSync('./dict');
const decompressed = decompressUsingDict(createDCtx(), buffer, dict);
TypeScript glue is provided under the MIT License, and the zstd is provided by Facebook under the BSD 3-Clause License.
0.0.27 (17. Feb, 2025)
FAQs
<img src="https://img.shields.io/npm/v/@bokuweb/zstd-wasm.svg" alt="Build Status"
The npm package @bokuweb/zstd-wasm receives a total of 4,767 weekly downloads. As such, @bokuweb/zstd-wasm popularity was classified as popular.
We found that @bokuweb/zstd-wasm demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Libxml2’s solo maintainer drops embargoed security fixes, highlighting the burden on unpaid volunteers who keep critical open source software secure.
Research
Security News
Socket investigates hidden protestware in npm packages that blocks user interaction and plays the Ukrainian anthem for Russian-language visitors.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.