zstd-wasm-vn 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +21 -0
- package/bundler/zstd_wasm_vn.d.ts +93 -0
- package/bundler/zstd_wasm_vn.js +5 -0
- package/bundler/zstd_wasm_vn_bg.js +330 -0
- package/bundler/zstd_wasm_vn_bg.wasm +0 -0
- package/bundler/zstd_wasm_vn_bg.wasm.d.ts +34 -0
- package/deno/zstd_wasm_vn.d.ts +93 -0
- package/deno/zstd_wasm_vn.js +327 -0
- package/deno/zstd_wasm_vn_bg.wasm +0 -0
- package/deno/zstd_wasm_vn_bg.wasm.d.ts +34 -0
- package/nodejs/zstd_wasm_vn.d.ts +93 -0
- package/nodejs/zstd_wasm_vn.js +333 -0
- package/nodejs/zstd_wasm_vn_bg.wasm +0 -0
- package/nodejs/zstd_wasm_vn_bg.wasm.d.ts +34 -0
- package/package.json +58 -0
- package/web/zstd_wasm_vn.d.ts +151 -0
- package/web/zstd_wasm_vn.js +434 -0
- package/web/zstd_wasm_vn_bg.wasm +0 -0
- package/web/zstd_wasm_vn_bg.wasm.d.ts +34 -0
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
|
|
2
|
+
let imports = {};
|
|
3
|
+
imports['__wbindgen_placeholder__'] = module.exports;
|
|
4
|
+
|
|
5
|
+
let cachedUint8ArrayMemory0 = null;
|
|
6
|
+
|
|
7
|
+
function getUint8ArrayMemory0() {
|
|
8
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
9
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
10
|
+
}
|
|
11
|
+
return cachedUint8ArrayMemory0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
15
|
+
|
|
16
|
+
cachedTextDecoder.decode();
|
|
17
|
+
|
|
18
|
+
function decodeText(ptr, len) {
|
|
19
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function getStringFromWasm0(ptr, len) {
|
|
23
|
+
ptr = ptr >>> 0;
|
|
24
|
+
return decodeText(ptr, len);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
let WASM_VECTOR_LEN = 0;
|
|
28
|
+
|
|
29
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
30
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
31
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
32
|
+
WASM_VECTOR_LEN = arg.length;
|
|
33
|
+
return ptr;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function isLikeNone(x) {
|
|
37
|
+
return x === undefined || x === null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function takeFromExternrefTable0(idx) {
|
|
41
|
+
const value = wasm.__wbindgen_export_0.get(idx);
|
|
42
|
+
wasm.__externref_table_dealloc(idx);
|
|
43
|
+
return value;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
47
|
+
ptr = ptr >>> 0;
|
|
48
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const ZstdFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
52
|
+
? { register: () => {}, unregister: () => {} }
|
|
53
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_zstd_free(ptr >>> 0, 1));
|
|
54
|
+
/**
|
|
55
|
+
* ZSTD compression and decompression for WebAssembly
|
|
56
|
+
*/
|
|
57
|
+
class Zstd {
|
|
58
|
+
|
|
59
|
+
__destroy_into_raw() {
|
|
60
|
+
const ptr = this.__wbg_ptr;
|
|
61
|
+
this.__wbg_ptr = 0;
|
|
62
|
+
ZstdFinalization.unregister(this);
|
|
63
|
+
return ptr;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
free() {
|
|
67
|
+
const ptr = this.__destroy_into_raw();
|
|
68
|
+
wasm.__wbg_zstd_free(ptr, 0);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Compresses data using Zstandard compression
|
|
72
|
+
*
|
|
73
|
+
* # Arguments
|
|
74
|
+
*
|
|
75
|
+
* * `data` - Input data to compress
|
|
76
|
+
* * `level` - Compression level (1-22, default 3). Higher = better compression but slower
|
|
77
|
+
* @param {Uint8Array} data
|
|
78
|
+
* @param {number | null} [level]
|
|
79
|
+
* @returns {Uint8Array}
|
|
80
|
+
*/
|
|
81
|
+
static compress(data, level) {
|
|
82
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
83
|
+
const len0 = WASM_VECTOR_LEN;
|
|
84
|
+
const ret = wasm.zstd_compress(ptr0, len0, isLikeNone(level) ? 0x100000001 : (level) >> 0);
|
|
85
|
+
if (ret[3]) {
|
|
86
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
87
|
+
}
|
|
88
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
89
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
90
|
+
return v2;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Decompresses Zstandard compressed data
|
|
94
|
+
*
|
|
95
|
+
* # Arguments
|
|
96
|
+
*
|
|
97
|
+
* * `compressed_data` - Zstandard compressed data
|
|
98
|
+
* @param {Uint8Array} compressed_data
|
|
99
|
+
* @returns {Uint8Array}
|
|
100
|
+
*/
|
|
101
|
+
static decompress(compressed_data) {
|
|
102
|
+
const ptr0 = passArray8ToWasm0(compressed_data, wasm.__wbindgen_malloc);
|
|
103
|
+
const len0 = WASM_VECTOR_LEN;
|
|
104
|
+
const ret = wasm.zstd_decompress(ptr0, len0);
|
|
105
|
+
if (ret[3]) {
|
|
106
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
107
|
+
}
|
|
108
|
+
var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
109
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
110
|
+
return v2;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Returns the recommended default compression level
|
|
114
|
+
* @returns {number}
|
|
115
|
+
*/
|
|
116
|
+
static defaultCompressionLevel() {
|
|
117
|
+
const ret = wasm.zstd_defaultCompressionLevel();
|
|
118
|
+
return ret;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Returns the minimum compression level
|
|
122
|
+
* @returns {number}
|
|
123
|
+
*/
|
|
124
|
+
static minCompressionLevel() {
|
|
125
|
+
const ret = wasm.zstd_minCompressionLevel();
|
|
126
|
+
return ret;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Returns the maximum compression level
|
|
130
|
+
* @returns {number}
|
|
131
|
+
*/
|
|
132
|
+
static maxCompressionLevel() {
|
|
133
|
+
const ret = wasm.zstd_maxCompressionLevel();
|
|
134
|
+
return ret;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Estimates the compressed size for planning purposes
|
|
138
|
+
* @param {number} input_size
|
|
139
|
+
* @returns {number}
|
|
140
|
+
*/
|
|
141
|
+
static compressBound(input_size) {
|
|
142
|
+
const ret = wasm.zstd_compressBound(input_size);
|
|
143
|
+
return ret >>> 0;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Calculates compression ratio (smaller = better compression)
|
|
147
|
+
* @param {number} original_size
|
|
148
|
+
* @param {number} compressed_size
|
|
149
|
+
* @returns {number}
|
|
150
|
+
*/
|
|
151
|
+
static compressionRatio(original_size, compressed_size) {
|
|
152
|
+
const ret = wasm.zstd_compressionRatio(original_size, compressed_size);
|
|
153
|
+
return ret;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Calculates space savings percentage
|
|
157
|
+
* @param {number} original_size
|
|
158
|
+
* @param {number} compressed_size
|
|
159
|
+
* @returns {number}
|
|
160
|
+
*/
|
|
161
|
+
static spaceSavings(original_size, compressed_size) {
|
|
162
|
+
const ret = wasm.zstd_spaceSavings(original_size, compressed_size);
|
|
163
|
+
return ret;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (Symbol.dispose) Zstd.prototype[Symbol.dispose] = Zstd.prototype.free;
|
|
167
|
+
|
|
168
|
+
exports.Zstd = Zstd;
|
|
169
|
+
|
|
170
|
+
const ZstdCompressorFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
171
|
+
? { register: () => {}, unregister: () => {} }
|
|
172
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_zstdcompressor_free(ptr >>> 0, 1));
|
|
173
|
+
/**
|
|
174
|
+
* Streaming compression for large data
|
|
175
|
+
*/
|
|
176
|
+
class ZstdCompressor {
|
|
177
|
+
|
|
178
|
+
__destroy_into_raw() {
|
|
179
|
+
const ptr = this.__wbg_ptr;
|
|
180
|
+
this.__wbg_ptr = 0;
|
|
181
|
+
ZstdCompressorFinalization.unregister(this);
|
|
182
|
+
return ptr;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
free() {
|
|
186
|
+
const ptr = this.__destroy_into_raw();
|
|
187
|
+
wasm.__wbg_zstdcompressor_free(ptr, 0);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Creates a new streaming compressor
|
|
191
|
+
* @param {number | null} [level]
|
|
192
|
+
*/
|
|
193
|
+
constructor(level) {
|
|
194
|
+
const ret = wasm.zstdcompressor_new(isLikeNone(level) ? 0x100000001 : (level) >> 0);
|
|
195
|
+
if (ret[2]) {
|
|
196
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
197
|
+
}
|
|
198
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
199
|
+
ZstdCompressorFinalization.register(this, this.__wbg_ptr, this);
|
|
200
|
+
return this;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Compresses a chunk of data
|
|
204
|
+
* @param {Uint8Array} data
|
|
205
|
+
*/
|
|
206
|
+
compress_chunk(data) {
|
|
207
|
+
const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
208
|
+
const len0 = WASM_VECTOR_LEN;
|
|
209
|
+
const ret = wasm.zstdcompressor_compress_chunk(this.__wbg_ptr, ptr0, len0);
|
|
210
|
+
if (ret[1]) {
|
|
211
|
+
throw takeFromExternrefTable0(ret[0]);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Finalizes compression and returns the compressed data
|
|
216
|
+
* @returns {Uint8Array}
|
|
217
|
+
*/
|
|
218
|
+
finalize() {
|
|
219
|
+
const ret = wasm.zstdcompressor_finalize(this.__wbg_ptr);
|
|
220
|
+
if (ret[3]) {
|
|
221
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
222
|
+
}
|
|
223
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
224
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
225
|
+
return v1;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Gets the current compression level
|
|
229
|
+
* @returns {number}
|
|
230
|
+
*/
|
|
231
|
+
get level() {
|
|
232
|
+
const ret = wasm.zstdcompressor_level(this.__wbg_ptr);
|
|
233
|
+
return ret;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
if (Symbol.dispose) ZstdCompressor.prototype[Symbol.dispose] = ZstdCompressor.prototype.free;
|
|
237
|
+
|
|
238
|
+
exports.ZstdCompressor = ZstdCompressor;
|
|
239
|
+
|
|
240
|
+
const ZstdDecompressorFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
241
|
+
? { register: () => {}, unregister: () => {} }
|
|
242
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_zstddecompressor_free(ptr >>> 0, 1));
|
|
243
|
+
/**
|
|
244
|
+
* Streaming decompression for large data
|
|
245
|
+
*/
|
|
246
|
+
class ZstdDecompressor {
|
|
247
|
+
|
|
248
|
+
__destroy_into_raw() {
|
|
249
|
+
const ptr = this.__wbg_ptr;
|
|
250
|
+
this.__wbg_ptr = 0;
|
|
251
|
+
ZstdDecompressorFinalization.unregister(this);
|
|
252
|
+
return ptr;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
free() {
|
|
256
|
+
const ptr = this.__destroy_into_raw();
|
|
257
|
+
wasm.__wbg_zstddecompressor_free(ptr, 0);
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Creates a new streaming decompressor
|
|
261
|
+
* @param {Uint8Array} compressed_data
|
|
262
|
+
*/
|
|
263
|
+
constructor(compressed_data) {
|
|
264
|
+
const ptr0 = passArray8ToWasm0(compressed_data, wasm.__wbindgen_malloc);
|
|
265
|
+
const len0 = WASM_VECTOR_LEN;
|
|
266
|
+
const ret = wasm.zstddecompressor_new(ptr0, len0);
|
|
267
|
+
if (ret[2]) {
|
|
268
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
269
|
+
}
|
|
270
|
+
this.__wbg_ptr = ret[0] >>> 0;
|
|
271
|
+
ZstdDecompressorFinalization.register(this, this.__wbg_ptr, this);
|
|
272
|
+
return this;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Decompresses a chunk of data
|
|
276
|
+
* @param {number} max_output_size
|
|
277
|
+
* @returns {Uint8Array}
|
|
278
|
+
*/
|
|
279
|
+
decompress_chunk(max_output_size) {
|
|
280
|
+
const ret = wasm.zstddecompressor_decompress_chunk(this.__wbg_ptr, max_output_size);
|
|
281
|
+
if (ret[3]) {
|
|
282
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
283
|
+
}
|
|
284
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
285
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
286
|
+
return v1;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Decompresses all remaining data
|
|
290
|
+
* @returns {Uint8Array}
|
|
291
|
+
*/
|
|
292
|
+
finalize() {
|
|
293
|
+
const ret = wasm.zstddecompressor_finalize(this.__wbg_ptr);
|
|
294
|
+
if (ret[3]) {
|
|
295
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
296
|
+
}
|
|
297
|
+
var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
298
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
299
|
+
return v1;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
if (Symbol.dispose) ZstdDecompressor.prototype[Symbol.dispose] = ZstdDecompressor.prototype.free;
|
|
303
|
+
|
|
304
|
+
exports.ZstdDecompressor = ZstdDecompressor;
|
|
305
|
+
|
|
306
|
+
exports.__wbg_wbindgenthrow_451ec1a8469d7eb6 = function(arg0, arg1) {
|
|
307
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
exports.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
|
|
311
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
312
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
313
|
+
return ret;
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
exports.__wbindgen_init_externref_table = function() {
|
|
317
|
+
const table = wasm.__wbindgen_export_0;
|
|
318
|
+
const offset = table.grow(4);
|
|
319
|
+
table.set(0, undefined);
|
|
320
|
+
table.set(offset + 0, undefined);
|
|
321
|
+
table.set(offset + 1, null);
|
|
322
|
+
table.set(offset + 2, true);
|
|
323
|
+
table.set(offset + 3, false);
|
|
324
|
+
;
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
const wasmPath = `${__dirname}/zstd_wasm_vn_bg.wasm`;
|
|
328
|
+
const wasmBytes = require('fs').readFileSync(wasmPath);
|
|
329
|
+
const wasmModule = new WebAssembly.Module(wasmBytes);
|
|
330
|
+
const wasm = exports.__wasm = new WebAssembly.Instance(wasmModule, imports).exports;
|
|
331
|
+
|
|
332
|
+
wasm.__wbindgen_start();
|
|
333
|
+
|
|
Binary file
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_zstd_free: (a: number, b: number) => void;
|
|
5
|
+
export const zstd_compress: (a: number, b: number, c: number) => [number, number, number, number];
|
|
6
|
+
export const zstd_decompress: (a: number, b: number) => [number, number, number, number];
|
|
7
|
+
export const zstd_defaultCompressionLevel: () => number;
|
|
8
|
+
export const zstd_minCompressionLevel: () => number;
|
|
9
|
+
export const zstd_maxCompressionLevel: () => number;
|
|
10
|
+
export const zstd_compressBound: (a: number) => number;
|
|
11
|
+
export const zstd_compressionRatio: (a: number, b: number) => number;
|
|
12
|
+
export const zstd_spaceSavings: (a: number, b: number) => number;
|
|
13
|
+
export const __wbg_zstdcompressor_free: (a: number, b: number) => void;
|
|
14
|
+
export const zstdcompressor_new: (a: number) => [number, number, number];
|
|
15
|
+
export const zstdcompressor_compress_chunk: (a: number, b: number, c: number) => [number, number];
|
|
16
|
+
export const zstdcompressor_finalize: (a: number) => [number, number, number, number];
|
|
17
|
+
export const zstdcompressor_level: (a: number) => number;
|
|
18
|
+
export const __wbg_zstddecompressor_free: (a: number, b: number) => void;
|
|
19
|
+
export const zstddecompressor_new: (a: number, b: number) => [number, number, number];
|
|
20
|
+
export const zstddecompressor_decompress_chunk: (a: number, b: number) => [number, number, number, number];
|
|
21
|
+
export const zstddecompressor_finalize: (a: number) => [number, number, number, number];
|
|
22
|
+
export const rust_zstd_wasm_shim_qsort: (a: number, b: number, c: number, d: number) => void;
|
|
23
|
+
export const rust_zstd_wasm_shim_malloc: (a: number) => number;
|
|
24
|
+
export const rust_zstd_wasm_shim_memcmp: (a: number, b: number, c: number) => number;
|
|
25
|
+
export const rust_zstd_wasm_shim_calloc: (a: number, b: number) => number;
|
|
26
|
+
export const rust_zstd_wasm_shim_free: (a: number) => void;
|
|
27
|
+
export const rust_zstd_wasm_shim_memcpy: (a: number, b: number, c: number) => number;
|
|
28
|
+
export const rust_zstd_wasm_shim_memmove: (a: number, b: number, c: number) => number;
|
|
29
|
+
export const rust_zstd_wasm_shim_memset: (a: number, b: number, c: number) => number;
|
|
30
|
+
export const __wbindgen_export_0: WebAssembly.Table;
|
|
31
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
32
|
+
export const __externref_table_dealloc: (a: number) => void;
|
|
33
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
34
|
+
export const __wbindgen_start: () => void;
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "zstd-wasm-vn",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"collaborators": [
|
|
5
|
+
"ndtao2020"
|
|
6
|
+
],
|
|
7
|
+
"description": "ZSTD for WebAssembly",
|
|
8
|
+
"version": "1.0.0",
|
|
9
|
+
"license": "MIT License",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/ndtao2020/zstd-wasm-vn"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"web/",
|
|
16
|
+
"deno/",
|
|
17
|
+
"nodejs/",
|
|
18
|
+
"bundler/"
|
|
19
|
+
],
|
|
20
|
+
"types": "./web/zstd_wasm_vn.d.ts",
|
|
21
|
+
"main": "./web/zstd_wasm_vn.js",
|
|
22
|
+
"sideEffects": [
|
|
23
|
+
"./snippets/*"
|
|
24
|
+
],
|
|
25
|
+
"exports": {
|
|
26
|
+
"./bundler": {
|
|
27
|
+
"types": "./bundler/zstd_wasm_vn.d.ts",
|
|
28
|
+
"require": "./bundler/zstd_wasm_vn.js",
|
|
29
|
+
"import": "./bundler/zstd_wasm_vn.js"
|
|
30
|
+
},
|
|
31
|
+
"./deno": {
|
|
32
|
+
"types": "./deno/zstd_wasm_vn.d.ts",
|
|
33
|
+
"require": "./deno/zstd_wasm_vn.js",
|
|
34
|
+
"import": "./deno/zstd_wasm_vn.js"
|
|
35
|
+
},
|
|
36
|
+
"./nodejs": {
|
|
37
|
+
"types": "./nodejs/zstd_wasm_vn.d.ts",
|
|
38
|
+
"require": "./nodejs/zstd_wasm_vn.js",
|
|
39
|
+
"import": "./nodejs/zstd_wasm_vn.js"
|
|
40
|
+
},
|
|
41
|
+
"./web": {
|
|
42
|
+
"types": "./web/zstd_wasm_vn.d.ts",
|
|
43
|
+
"require": "./web/zstd_wasm_vn.js",
|
|
44
|
+
"import": "./web/zstd_wasm_vn.js"
|
|
45
|
+
},
|
|
46
|
+
".": {
|
|
47
|
+
"types": "./web/zstd_wasm_vn.d.ts",
|
|
48
|
+
"require": "./web/zstd_wasm_vn.js",
|
|
49
|
+
"import": "./web/zstd_wasm_vn.js"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"keywords": [
|
|
53
|
+
"zstd",
|
|
54
|
+
"wasm",
|
|
55
|
+
"webassembly",
|
|
56
|
+
"vn"
|
|
57
|
+
]
|
|
58
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* ZSTD compression and decompression for WebAssembly
|
|
5
|
+
*/
|
|
6
|
+
export class Zstd {
|
|
7
|
+
private constructor();
|
|
8
|
+
free(): void;
|
|
9
|
+
[Symbol.dispose](): void;
|
|
10
|
+
/**
|
|
11
|
+
* Compresses data using Zstandard compression
|
|
12
|
+
*
|
|
13
|
+
* # Arguments
|
|
14
|
+
*
|
|
15
|
+
* * `data` - Input data to compress
|
|
16
|
+
* * `level` - Compression level (1-22, default 3). Higher = better compression but slower
|
|
17
|
+
*/
|
|
18
|
+
static compress(data: Uint8Array, level?: number | null): Uint8Array;
|
|
19
|
+
/**
|
|
20
|
+
* Decompresses Zstandard compressed data
|
|
21
|
+
*
|
|
22
|
+
* # Arguments
|
|
23
|
+
*
|
|
24
|
+
* * `compressed_data` - Zstandard compressed data
|
|
25
|
+
*/
|
|
26
|
+
static decompress(compressed_data: Uint8Array): Uint8Array;
|
|
27
|
+
/**
|
|
28
|
+
* Returns the recommended default compression level
|
|
29
|
+
*/
|
|
30
|
+
static defaultCompressionLevel(): number;
|
|
31
|
+
/**
|
|
32
|
+
* Returns the minimum compression level
|
|
33
|
+
*/
|
|
34
|
+
static minCompressionLevel(): number;
|
|
35
|
+
/**
|
|
36
|
+
* Returns the maximum compression level
|
|
37
|
+
*/
|
|
38
|
+
static maxCompressionLevel(): number;
|
|
39
|
+
/**
|
|
40
|
+
* Estimates the compressed size for planning purposes
|
|
41
|
+
*/
|
|
42
|
+
static compressBound(input_size: number): number;
|
|
43
|
+
/**
|
|
44
|
+
* Calculates compression ratio (smaller = better compression)
|
|
45
|
+
*/
|
|
46
|
+
static compressionRatio(original_size: number, compressed_size: number): number;
|
|
47
|
+
/**
|
|
48
|
+
* Calculates space savings percentage
|
|
49
|
+
*/
|
|
50
|
+
static spaceSavings(original_size: number, compressed_size: number): number;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Streaming compression for large data
|
|
54
|
+
*/
|
|
55
|
+
export class ZstdCompressor {
|
|
56
|
+
free(): void;
|
|
57
|
+
[Symbol.dispose](): void;
|
|
58
|
+
/**
|
|
59
|
+
* Creates a new streaming compressor
|
|
60
|
+
*/
|
|
61
|
+
constructor(level?: number | null);
|
|
62
|
+
/**
|
|
63
|
+
* Compresses a chunk of data
|
|
64
|
+
*/
|
|
65
|
+
compress_chunk(data: Uint8Array): void;
|
|
66
|
+
/**
|
|
67
|
+
* Finalizes compression and returns the compressed data
|
|
68
|
+
*/
|
|
69
|
+
finalize(): Uint8Array;
|
|
70
|
+
/**
|
|
71
|
+
* Gets the current compression level
|
|
72
|
+
*/
|
|
73
|
+
readonly level: number;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Streaming decompression for large data
|
|
77
|
+
*/
|
|
78
|
+
export class ZstdDecompressor {
|
|
79
|
+
free(): void;
|
|
80
|
+
[Symbol.dispose](): void;
|
|
81
|
+
/**
|
|
82
|
+
* Creates a new streaming decompressor
|
|
83
|
+
*/
|
|
84
|
+
constructor(compressed_data: Uint8Array);
|
|
85
|
+
/**
|
|
86
|
+
* Decompresses a chunk of data
|
|
87
|
+
*/
|
|
88
|
+
decompress_chunk(max_output_size: number): Uint8Array;
|
|
89
|
+
/**
|
|
90
|
+
* Decompresses all remaining data
|
|
91
|
+
*/
|
|
92
|
+
finalize(): Uint8Array;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
96
|
+
|
|
97
|
+
export interface InitOutput {
|
|
98
|
+
readonly memory: WebAssembly.Memory;
|
|
99
|
+
readonly __wbg_zstd_free: (a: number, b: number) => void;
|
|
100
|
+
readonly zstd_compress: (a: number, b: number, c: number) => [number, number, number, number];
|
|
101
|
+
readonly zstd_decompress: (a: number, b: number) => [number, number, number, number];
|
|
102
|
+
readonly zstd_defaultCompressionLevel: () => number;
|
|
103
|
+
readonly zstd_minCompressionLevel: () => number;
|
|
104
|
+
readonly zstd_maxCompressionLevel: () => number;
|
|
105
|
+
readonly zstd_compressBound: (a: number) => number;
|
|
106
|
+
readonly zstd_compressionRatio: (a: number, b: number) => number;
|
|
107
|
+
readonly zstd_spaceSavings: (a: number, b: number) => number;
|
|
108
|
+
readonly __wbg_zstdcompressor_free: (a: number, b: number) => void;
|
|
109
|
+
readonly zstdcompressor_new: (a: number) => [number, number, number];
|
|
110
|
+
readonly zstdcompressor_compress_chunk: (a: number, b: number, c: number) => [number, number];
|
|
111
|
+
readonly zstdcompressor_finalize: (a: number) => [number, number, number, number];
|
|
112
|
+
readonly zstdcompressor_level: (a: number) => number;
|
|
113
|
+
readonly __wbg_zstddecompressor_free: (a: number, b: number) => void;
|
|
114
|
+
readonly zstddecompressor_new: (a: number, b: number) => [number, number, number];
|
|
115
|
+
readonly zstddecompressor_decompress_chunk: (a: number, b: number) => [number, number, number, number];
|
|
116
|
+
readonly zstddecompressor_finalize: (a: number) => [number, number, number, number];
|
|
117
|
+
readonly rust_zstd_wasm_shim_qsort: (a: number, b: number, c: number, d: number) => void;
|
|
118
|
+
readonly rust_zstd_wasm_shim_malloc: (a: number) => number;
|
|
119
|
+
readonly rust_zstd_wasm_shim_memcmp: (a: number, b: number, c: number) => number;
|
|
120
|
+
readonly rust_zstd_wasm_shim_calloc: (a: number, b: number) => number;
|
|
121
|
+
readonly rust_zstd_wasm_shim_free: (a: number) => void;
|
|
122
|
+
readonly rust_zstd_wasm_shim_memcpy: (a: number, b: number, c: number) => number;
|
|
123
|
+
readonly rust_zstd_wasm_shim_memmove: (a: number, b: number, c: number) => number;
|
|
124
|
+
readonly rust_zstd_wasm_shim_memset: (a: number, b: number, c: number) => number;
|
|
125
|
+
readonly __wbindgen_export_0: WebAssembly.Table;
|
|
126
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
127
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
128
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
129
|
+
readonly __wbindgen_start: () => void;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
133
|
+
/**
|
|
134
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
135
|
+
* a precompiled `WebAssembly.Module`.
|
|
136
|
+
*
|
|
137
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
138
|
+
*
|
|
139
|
+
* @returns {InitOutput}
|
|
140
|
+
*/
|
|
141
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
145
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
146
|
+
*
|
|
147
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
148
|
+
*
|
|
149
|
+
* @returns {Promise<InitOutput>}
|
|
150
|
+
*/
|
|
151
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|