UNPKG

@dstanesc/wasm-chunking-fastcdc-webpack

Version:

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

63 lines (62 loc) 2.22 kB
/* tslint:disable */ /* eslint-disable */ /** * * 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(); * ``` * @param {Uint8Array} source * @param {number} min_size * @param {number} avg_size * @param {number} max_size * @returns {Uint32Array} */ export function compute_chunks(source: Uint8Array, min_size: number, avg_size: number, max_size: number): Uint32Array; /** * * 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` * * No js friendly chunking specification range validation * Example: * * ``` * use wasm_chunking_fastcdc::compute_chunks_nocheck; * 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_nocheck(slice, min_size, avg_size, max_size); * ``` * @param {Uint8Array} source * @param {number} min_size * @param {number} avg_size * @param {number} max_size * @returns {Uint32Array} */ export function compute_chunks_nocheck(source: Uint8Array, min_size: number, avg_size: number, max_size: number): Uint32Array;