@dstanesc/wasm-chunking-fastcdc-node

中文文档
0.1.1发布于 2022/09/20MIT OR Apache-2.0TypeScriptCommonJS零依赖近 30 天下载 6049

This crate generates WebAssembly bindings to the FastCDC content defined slicing library

原始使用文档
文档目录11 节
  1. Wasm Chunking Fastcdc
  2. Install for nodejs usage
  3. Install for bundler usage
  4. Usage TypeScript
  5. Wasm build requirements
  6. Wasm build
  7. Wasm test
  8. Pack for local usage
  9. Rust API
  10. Function wasm_chunking_fastcdc::compute_chunks
  11. License

Wasm Chunking Fastcdc

This crate generates WebAssembly bindings to the FastCDC content defined slicing library.

Install for nodejs usage

npm install @dstanesc/wasm-chunking-fastcdc-node

Install for bundler usage

npm install @dstanesc/wasm-chunking-fastcdc-webpack

Usage TypeScript

//import { compute_chunks } from "@dstanesc/wasm-chunking-fastcdc-node"
import { compute_chunks } from "@dstanesc/wasm-chunking-fastcdc-webpack"
const buf: Uint8Array  = ...
// chunking  spec: min_size 16 KB, avg size 32 KB, max size 64 KB
const offsets: Uint32Array = compute_chunks(buf, 16384, 32768, 65536)   

Wasm build requirements

Wasm build

wasm-pack build --out-dir pkg/webpack --out-name chunking --target bundler --scope dstanesc
wasm-pack build --out-dir pkg/node --out-name chunking --target nodejs --scope dstanesc

Wasm test

Interactive mode, eg. to check debugging info in the console

wasm-pack test --firefox

Headless mode

wasm-pack test --headless --firefox

Pack for local usage

npm pack pkg/node/
npm pack pkg/webpack/

Rust API

Function wasm_chunking_fastcdc::compute_chunks

pub fn compute_chunks(
    source: &[u8], 
    min_size: u32, 
    avg_size: u32, 
    max_size: u32
) -> Result<Vec<u32>, RangeError>

Compute chunks from a given slice of bytes.

The min_size specifies the preferred minimum chunk size, max_size the preferred maximum chunk size; the avg_size is the desired “normal size” of the chunks. The smallest acceptable min_size is 64 bytes and likewise 256 bytes and 1024 bytes for avg_size and respectively max_size

A js_sys::RangeError is returned when the above chunking specification is out of range.

Example:

use wasm_chunking_fastcdc::compute_chunks;
let data: Vec<u8> = br"Lorem ipsum dolor sit amet, consectetur adipiscing elit...put more bits in here...".to_vec();
let slice: &[u8] = &data;
let min_size: u32 = 64;
let avg_size: u32 = 256;
let max_size: u32 = 1024;
let offsets: Vec<u32> = compute_chunks(slice, min_size, avg_size, max_size).unwrap();

License

Licensed under either Apache 2.0 or MIT at your option.

版本与发布记录

@dstanesc/wasm-chunking-fastcdc-node 共发布 2 个版本,首次发布于 2022/09/20;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.1.1latest2022/09/204 年前
0.1.02022/09/204 年前

关于 @dstanesc/wasm-chunking-fastcdc-node 的常见问题

@dstanesc/wasm-chunking-fastcdc-node 是什么?

This crate generates WebAssembly bindings to the FastCDC content defined slicing library

如何安装 @dstanesc/wasm-chunking-fastcdc-node?

在项目目录运行 npm install @dstanesc/wasm-chunking-fastcdc-node,或使用 pnpm add / yarn add / bun add。

@dstanesc/wasm-chunking-fastcdc-node 支持 TypeScript 吗?

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

@dstanesc/wasm-chunking-fastcdc-node 支持 ESM 还是 CommonJS?

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

@dstanesc/wasm-chunking-fastcdc-node 可以商用吗?

@dstanesc/wasm-chunking-fastcdc-node 使用 MIT OR Apache-2.0 许可。可在 MIT、Apache-2.0 中任选其一遵守。选择 MIT 时,宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@dstanesc/wasm-chunking-fastcdc-node 的下载量有多少?

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

@dstanesc/wasm-chunking-fastcdc-node 还在维护吗?

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