@foxglove/wasm-zstd

中文文档
1.0.1发布于 2023/02/09MITTypeScriptCommonJS零依赖近 30 天下载 23.1万

https://github.com/facebook/zstd (中文(简体) ) 编译为WebAssembly,并作为高级TypeScript/JavaScript API被曝光. 公关欢迎!

中文使用文档
文档目录6 节
  1. API 密码
  2. 使用浏览器中的模块
  3. 地方发展
  4. 许可证
  5. 释放
  6. 保持联系

@foxglove/wasm-zstd (英语)

https://github.com/facebook/zstd (中文(简体) ) 编译为WebAssembly,并作为高级TypeScript/JavaScript API被曝光. 公关欢迎!

API 密码

@foxglove/wasm-zstd 输出 :

export const isLoaded: Promise<boolean>;
export function compressBound(size: number): number;
export function compress(buffer: Uint8Array, compressionLevel?: number): Buffer;
export function decompress(buffer: Uint8Array, size: number): Buffer;

以下是用这个库压缩后解压的例子:

import fs from "fs/promises";
import zstd from "@foxglove/wasm-zstd";

async function main() {
  const inputData = await fs.readFile("input.txt");

  // Wait for the wasm module to load
  await zstd.isLoaded;

  // Compress and save to a file with zstd compression level 3
  const compressedBytes = zstd.compress(inputData, 3);
  await fs.writeFile("compressed.zst", compressedBytes);

  // Currently you need to know the size of the output buffer so the wasm runtime
  // can allocate enough bytes to decompress into
  const outputSize = inputData.byteLength;

  // Decompress
  const decompressedBytes = zstd.decompress(compressedBytes, inputData.byteLength);
  assert(decompressedBytes.byteLength === inputData.byteLength);
}

使用浏览器中的模块

编译的网络大会模块分为两个部分:a .js 边和 a .wasm 边 在浏览器中 .js 侧面需要下载 .wasm 从服务器侧取,以便编译它。 有一个 说明文件中的更多信息。 。 。 .

地方发展

  1. 运行 yarn install 以安装依赖.
  2. 运行 yarn build 在 Docker 容器内引用 emcc 并编译代码 wasm-zstd.c 以及所需的zstd源文件。 输出将会在 dist/ 在主机上.
  3. 运行 yarn test 进行测试.

许可证

@foxglove/wasm-zstd 获得许可 MIT 许可证。 。 。 .

释放

  1. 运行 yarn version --[major|minor|patch] 切换到凸起版本
  2. 运行 git push && git push --tags 以驱动新标签
  3. GitHub 动作会照顾剩下的

保持联系

加入我们 黑频道 问问题 分享反馈 随时了解我们团队的工作.

版本与发布记录

@foxglove/wasm-zstd 共发布 2 个版本,首次发布于 2023/02/09;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.1latest2023/02/093 年前
1.0.02023/02/093 年前

关于 @foxglove/wasm-zstd 的常见问题

@foxglove/wasm-zstd 是什么?

https://github.com/facebook/zstd (中文(简体) ) 编译为WebAssembly,并作为高级TypeScript/JavaScript API被曝光. 公关欢迎!

如何安装 @foxglove/wasm-zstd?

在项目目录运行 npm install @foxglove/wasm-zstd,或使用 pnpm add / yarn add / bun add。

@foxglove/wasm-zstd 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@foxglove/wasm-zstd 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@foxglove/wasm-zstd 可以商用吗?

@foxglove/wasm-zstd 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@foxglove/wasm-zstd 的下载量有多少?

根据 npm 官方下载统计,@foxglove/wasm-zstd 在 2026/10/16 – 2026/11/14 这 30 天内被下载 231,255 次,日均约 7,709 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@foxglove/wasm-zstd 还在维护吗?

最新版本 1.0.1 发布于 2023/02/09(3 年前);至今共发布 2 个版本,其中过去 12 个月发布了 0 个;首次发布于 2023/02/09。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。