@addmaple/lz4 0.1.0 → 0.1.1
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/README.md +3 -2
- package/dist/core.d.ts +1 -2
- package/dist/core.js +3 -18
- package/dist/custom.js +6 -6
- package/dist/wasm/lz4.base.wasm +0 -0
- package/dist/wasm/lz4.simd.wasm +0 -0
- package/dist/wasm-inline/lz4.base.wasm.js +1 -1
- package/dist/wasm-inline/lz4.simd.wasm.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -37,11 +37,12 @@ const compressed = await compress(input);
|
|
|
37
37
|
### `init()`
|
|
38
38
|
Initialize the WASM module.
|
|
39
39
|
|
|
40
|
-
### `compress(input
|
|
40
|
+
### `compress(input)`
|
|
41
41
|
- `input`: `Uint8Array`
|
|
42
|
-
- `options.level`: 1 or 9 (default: 1)
|
|
43
42
|
- Returns: `Promise<Uint8Array>`
|
|
44
43
|
|
|
44
|
+
Note: LZ4 is a single-speed algorithm optimized for maximum throughput. Unlike Brotli/Gzip, it doesn't have compression levels.
|
|
45
|
+
|
|
45
46
|
## Sponsor
|
|
46
47
|
|
|
47
48
|
Development of this module was sponsored by [addmaple.com](https://addmaple.com) — a modern data analysis platform.
|
package/dist/core.d.ts
CHANGED
|
@@ -6,5 +6,4 @@ export function memoryU8(): Uint8Array;
|
|
|
6
6
|
export function alloc(len: number): number;
|
|
7
7
|
export function free(ptr: number, len: number): void;
|
|
8
8
|
|
|
9
|
-
export function
|
|
10
|
-
export function compress_level_9(input: WasmInput): Promise<Uint8Array>;
|
|
9
|
+
export function compress_lz4(input: WasmInput): Promise<Uint8Array>;
|
package/dist/core.js
CHANGED
|
@@ -79,12 +79,12 @@ function callWasm(abi, input, outLen, reuse) {
|
|
|
79
79
|
return { inPtr, outPtr, len, outLen, written };
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
async function
|
|
82
|
+
async function compress_lz4(input) {
|
|
83
83
|
await ensureReady();
|
|
84
84
|
const view = toBytes(input);
|
|
85
85
|
const len = view.byteLength;
|
|
86
86
|
const outLen = len + 1024;
|
|
87
|
-
const { outPtr, written, inPtr } = callWasm("
|
|
87
|
+
const { outPtr, written, inPtr } = callWasm("compress_lz4", view, outLen, null);
|
|
88
88
|
|
|
89
89
|
const result = memoryU8().slice(outPtr, outPtr + written);
|
|
90
90
|
|
|
@@ -92,19 +92,4 @@ async function compress_level_1(input) {
|
|
|
92
92
|
free(outPtr, outLen);
|
|
93
93
|
return result;
|
|
94
94
|
}
|
|
95
|
-
export {
|
|
96
|
-
|
|
97
|
-
async function compress_level_9(input) {
|
|
98
|
-
await ensureReady();
|
|
99
|
-
const view = toBytes(input);
|
|
100
|
-
const len = view.byteLength;
|
|
101
|
-
const outLen = len + 1024;
|
|
102
|
-
const { outPtr, written, inPtr } = callWasm("compress_lz4_level_9", view, outLen, null);
|
|
103
|
-
|
|
104
|
-
const result = memoryU8().slice(outPtr, outPtr + written);
|
|
105
|
-
|
|
106
|
-
free(inPtr, len);
|
|
107
|
-
free(outPtr, outLen);
|
|
108
|
-
return result;
|
|
109
|
-
}
|
|
110
|
-
export { compress_level_9 };
|
|
95
|
+
export { compress_lz4 };
|
package/dist/custom.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { compress_lz4, wasmExports } from './core.js';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
// LZ4 is a single-speed algorithm optimized for maximum throughput.
|
|
4
|
+
// Unlike Brotli/Gzip, it doesn't have compression levels.
|
|
5
|
+
export async function compress(input) {
|
|
6
6
|
try {
|
|
7
|
-
|
|
8
|
-
return compress_level_9(input);
|
|
7
|
+
return compress_lz4(input);
|
|
9
8
|
} catch (error) {
|
|
10
9
|
throw new Error(`Compression failed: ${error.message}`);
|
|
11
10
|
}
|
|
12
11
|
}
|
|
13
12
|
|
|
14
13
|
export { wasmExports };
|
|
14
|
+
|
package/dist/wasm/lz4.base.wasm
CHANGED
|
Binary file
|
package/dist/wasm/lz4.simd.wasm
CHANGED
|
Binary file
|