@cloudpss/compress 0.4.13 → 0.4.15
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/benchmark.js +20 -11
- package/dist/gzip/index.js +2 -2
- package/dist/gzip/index.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -5
- package/src/gzip/index.ts +2 -2
- package/src/index.ts +1 -1
- package/yarn-error.log +4520 -0
- package/dist/zstd/index-browser.d.ts +0 -2
- package/dist/zstd/index-browser.js +0 -3
- package/dist/zstd/index-browser.js.map +0 -1
- package/dist/zstd/index.d.ts +0 -4
- package/dist/zstd/index.js +0 -38
- package/dist/zstd/index.js.map +0 -1
- package/dist/zstd/wasm/compress.d.ts +0 -2
- package/dist/zstd/wasm/compress.js +0 -28
- package/dist/zstd/wasm/compress.js.map +0 -1
- package/dist/zstd/wasm/decompress.d.ts +0 -2
- package/dist/zstd/wasm/decompress.js +0 -32
- package/dist/zstd/wasm/decompress.js.map +0 -1
- package/dist/zstd/wasm/module.d.ts +0 -2
- package/dist/zstd/wasm/module.js +0 -4
- package/dist/zstd/wasm/module.js.map +0 -1
- package/src/zstd/index-browser.ts +0 -2
- package/src/zstd/index.ts +0 -39
- package/src/zstd/wasm/compress.ts +0 -27
- package/src/zstd/wasm/decompress.ts +0 -32
- package/src/zstd/wasm/module.ts +0 -5
- package/wasm/zstd.g.d.ts +0 -17
- package/wasm/zstd.g.js +0 -27
package/benchmark.js
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
import prettyBytes from 'pretty-bytes';
|
|
3
3
|
import wasmFlate from 'wasm-flate';
|
|
4
4
|
import zlib from 'zlib';
|
|
5
|
-
import
|
|
6
|
-
import * as myZstd from './dist/zstd/index-browser.js';
|
|
5
|
+
import bokuwebZstd from '@bokuweb/zstd-wasm';
|
|
7
6
|
import cppzst from '@xingrz/cppzst';
|
|
7
|
+
import * as myZstdWasm from '@cloudpss/zstd/wasm';
|
|
8
|
+
import * as myZstdNapi from '@cloudpss/zstd';
|
|
8
9
|
import pako from 'pako';
|
|
9
10
|
import files from '../../benchmark-files/index.js';
|
|
10
11
|
import { createRequire } from 'node:module';
|
|
@@ -15,7 +16,7 @@ const brotli = createRequire(import.meta.url)('brotli-wasm');
|
|
|
15
16
|
const t = (/** @type {number} */ time) => time.toFixed(2) + 'ms';
|
|
16
17
|
const pb = (/** @type {number} */ size) => prettyBytes(size, { binary: true });
|
|
17
18
|
|
|
18
|
-
await
|
|
19
|
+
await bokuwebZstd.init();
|
|
19
20
|
|
|
20
21
|
/** 生成测试 */
|
|
21
22
|
function createTest(
|
|
@@ -41,14 +42,14 @@ const tests = [
|
|
|
41
42
|
createTest('gzip -d (wasm)', wasmFlate.gzip_encode_raw, wasmFlate.gzip_decode_raw),
|
|
42
43
|
createTest('gzip -d (node)', zlib.gzipSync, zlib.gunzipSync),
|
|
43
44
|
createTest('gzip -d (pako)', pako.gzip, pako.ungzip),
|
|
44
|
-
createTest('zstd -3 (Oz,wasm)', (buf) =>
|
|
45
|
-
createTest('zstd -3 (O3,wasm)', (buf) =>
|
|
46
|
-
createTest('zstd -4 (O3,wasm)', (buf) =>
|
|
47
|
-
createTest('zstd -4 (
|
|
48
|
-
createTest('zstd -
|
|
49
|
-
createTest('zstd -
|
|
50
|
-
createTest('zstd -10 (
|
|
51
|
-
createTest('zstd -10 (
|
|
45
|
+
createTest('zstd -3 (Oz,wasm)', (buf) => bokuwebZstd.compress(buf, 3), bokuwebZstd.decompress),
|
|
46
|
+
createTest('zstd -3 (O3,wasm)', (buf) => myZstdWasm.compress(buf, 3), myZstdWasm.decompress),
|
|
47
|
+
createTest('zstd -4 (O3,wasm)', (buf) => myZstdWasm.compress(buf, 4), myZstdWasm.decompress),
|
|
48
|
+
createTest('zstd -4 (cppzst)', (buf) => cppzst.compressSync(buf, { level: 4 }), cppzst.decompressSync),
|
|
49
|
+
createTest('zstd -4 (napi)', (buf) => myZstdNapi.compress(buf, 4), myZstdNapi.decompress),
|
|
50
|
+
createTest('zstd -10 (O3,wasm)', (buf) => myZstdWasm.compress(buf, 10), myZstdWasm.decompress),
|
|
51
|
+
createTest('zstd -10 (cppzst)', (buf) => cppzst.compressSync(buf, { level: 10 }), cppzst.decompressSync),
|
|
52
|
+
createTest('zstd -10 (napi)', (buf) => myZstdNapi.compress(buf, 10), myZstdNapi.decompress),
|
|
52
53
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-argument
|
|
53
54
|
createTest('br -1 (wasm)', (buf) => brotli.compress(buf, { quality: 1 }), brotli.decompress),
|
|
54
55
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-argument
|
|
@@ -69,6 +70,14 @@ const tests = [
|
|
|
69
70
|
}),
|
|
70
71
|
zlib.brotliDecompressSync,
|
|
71
72
|
),
|
|
73
|
+
createTest(
|
|
74
|
+
`br -8 (node)`,
|
|
75
|
+
(buf) =>
|
|
76
|
+
zlib.brotliCompressSync(buf, {
|
|
77
|
+
params: { [zlib.constants.BROTLI_PARAM_QUALITY]: 8 },
|
|
78
|
+
}),
|
|
79
|
+
zlib.brotliDecompressSync,
|
|
80
|
+
),
|
|
72
81
|
];
|
|
73
82
|
for await (const { file, data } of files()) {
|
|
74
83
|
console.log(`File: ${file} \tRaw: ${pb(data.length)}`);
|
package/dist/gzip/index.js
CHANGED
|
@@ -5,7 +5,7 @@ export function compress(data) {
|
|
|
5
5
|
gzip(data, (err, result) => {
|
|
6
6
|
if (err || !result)
|
|
7
7
|
reject(err);
|
|
8
|
-
resolve(
|
|
8
|
+
resolve(result);
|
|
9
9
|
});
|
|
10
10
|
});
|
|
11
11
|
}
|
|
@@ -15,7 +15,7 @@ export function decompress(data) {
|
|
|
15
15
|
gunzip(data, (err, result) => {
|
|
16
16
|
if (err || !result)
|
|
17
17
|
reject(err);
|
|
18
|
-
resolve(
|
|
18
|
+
resolve(result);
|
|
19
19
|
});
|
|
20
20
|
});
|
|
21
21
|
}
|
package/dist/gzip/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/gzip/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEpC,SAAS;AACT,MAAM,UAAU,QAAQ,CAAC,IAAgB;IACrC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACnC,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;YACvB,IAAI,GAAG,IAAI,CAAC,MAAM;gBAAE,MAAM,CAAC,GAAG,CAAC,CAAC;YAChC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/gzip/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAEpC,SAAS;AACT,MAAM,UAAU,QAAQ,CAAC,IAAgB;IACrC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACnC,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;YACvB,IAAI,GAAG,IAAI,CAAC,MAAM;gBAAE,MAAM,CAAC,GAAG,CAAC,CAAC;YAChC,OAAO,CAAC,MAAM,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC;AAED,SAAS;AACT,MAAM,UAAU,UAAU,CAAC,IAAgB;IACvC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACnC,MAAM,CAAC,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;YACzB,IAAI,GAAG,IAAI,CAAC,MAAM;gBAAE,MAAM,CAAC,GAAG,CAAC,CAAC;YAChC,OAAO,CAAC,MAAM,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,cAAc;AACd,MAAM,CAAC,MAAM,aAAa,GAAG;IACzB,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;IAC9B,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;CACrB,CAAC;AAEF,MAAM,OAAO,GAAG;IACZ,IAAI,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,cAAc;AACd,MAAM,CAAC,MAAM,aAAa,GAAG;IACzB,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;IAC9B,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;CACrB,CAAC;AAEF,MAAM,OAAO,GAAG;IACZ,IAAI,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC;IACpC,IAAI,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,iBAAiB,CAAC;CACxC,CAAC;AAEF,YAAY;AACZ,SAAS,OAAO,CAAC,SAAgD;IAC7D,IAAI,CAAC,CAAC,SAAS,IAAI,OAAO,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,kCAAkC,SAAS,EAAE,CAAC,CAAC;IAC5F,OAAO,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;AAChC,CAAC;AAED,eAAe;AACf,MAAM,UAAU,QAAQ,CAAC,IAAgB,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AAC;QAC1D,MAAM,CAAC,SAAS,GAAG,MAAM,CAAC;QAC1B,OAAO,MAAM,CAAC;KACjB;IAED,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAsB,CAAC;IAClG,MAAM,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudpss/compress",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.15",
|
|
4
4
|
"author": "CloudPSS",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -23,15 +23,14 @@
|
|
|
23
23
|
"benchmark": "node ./benchmark"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
+
"@cloudpss/zstd": "^0.2.0",
|
|
26
27
|
"pako": "^2.1.0"
|
|
27
28
|
},
|
|
28
|
-
"optionalDependencies": {
|
|
29
|
-
"@xingrz/cppzst": "^2.1.0-alpha.8"
|
|
30
|
-
},
|
|
31
29
|
"devDependencies": {
|
|
32
30
|
"@bokuweb/zstd-wasm": "^0.0.20",
|
|
33
|
-
"@types/node": "^18.15.
|
|
31
|
+
"@types/node": "^18.15.12",
|
|
34
32
|
"@types/pako": "^2.0.0",
|
|
33
|
+
"@xingrz/cppzst": "^2.1.0-alpha.8",
|
|
35
34
|
"brotli-wasm": "^1.3.1",
|
|
36
35
|
"pretty-bytes": "^6.1.0",
|
|
37
36
|
"type-fest": "^3.8.0",
|
package/src/gzip/index.ts
CHANGED
|
@@ -5,7 +5,7 @@ export function compress(data: Uint8Array): Promise<Uint8Array> {
|
|
|
5
5
|
return new Promise((resolve, reject) => {
|
|
6
6
|
gzip(data, (err, result) => {
|
|
7
7
|
if (err || !result) reject(err);
|
|
8
|
-
resolve(
|
|
8
|
+
resolve(result);
|
|
9
9
|
});
|
|
10
10
|
});
|
|
11
11
|
}
|
|
@@ -15,7 +15,7 @@ export function decompress(data: Uint8Array): Promise<Uint8Array> {
|
|
|
15
15
|
return new Promise((resolve, reject) => {
|
|
16
16
|
gunzip(data, (err, result) => {
|
|
17
17
|
if (err || !result) reject(err);
|
|
18
|
-
resolve(
|
|
18
|
+
resolve(result);
|
|
19
19
|
});
|
|
20
20
|
});
|
|
21
21
|
}
|