
Research
/Security News
Toptal’s GitHub Organization Hijacked: 10 Malicious Packages Published
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
@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 7,160 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.
Research
/Security News
Threat actors hijacked Toptal’s GitHub org, publishing npm packages with malicious payloads that steal tokens and attempt to wipe victim systems.
Research
/Security News
Socket researchers investigate 4 malicious npm and PyPI packages with 56,000+ downloads that install surveillance malware.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.