@wenex/sdk 1.2.0 → 1.2.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.
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { BrotliWasmType } from 'brotli-wasm';
|
|
2
2
|
export declare class Brotli {
|
|
3
|
-
protected brotli?: BrotliWasmType;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
static new(): Promise<Brotli>;
|
|
3
|
+
protected static brotli?: BrotliWasmType;
|
|
4
|
+
protected static instantiate(): Promise<any>;
|
|
5
|
+
static compress(buf: Uint8Array<ArrayBufferLike>, quality?: number): Promise<Buffer<ArrayBuffer>>;
|
|
6
|
+
static decompress(buf: Uint8Array<ArrayBufferLike>): Promise<Buffer<ArrayBuffer>>;
|
|
8
7
|
}
|
|
@@ -2,23 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Brotli = void 0;
|
|
4
4
|
class Brotli {
|
|
5
|
-
|
|
6
|
-
if (!this.brotli)
|
|
7
|
-
throw Error('brotli helper is not initialized');
|
|
8
|
-
return Buffer.from(this.brotli.compress(buf, { quality }));
|
|
9
|
-
}
|
|
10
|
-
decompress(buf) {
|
|
11
|
-
if (!this.brotli)
|
|
12
|
-
throw Error('brotli helper is not initialized');
|
|
13
|
-
return Buffer.from(this.brotli.decompress(buf));
|
|
14
|
-
}
|
|
15
|
-
async init() {
|
|
5
|
+
static async instantiate() {
|
|
16
6
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
17
|
-
this.brotli = this.brotli ?? (await require('brotli-wasm'));
|
|
18
|
-
|
|
7
|
+
return (this.brotli = this.brotli ?? (await require('brotli-wasm')));
|
|
8
|
+
}
|
|
9
|
+
static async compress(buf, quality = 8) {
|
|
10
|
+
return Buffer.from((await this.instantiate()).compress(buf, { quality }));
|
|
19
11
|
}
|
|
20
|
-
static async
|
|
21
|
-
return
|
|
12
|
+
static async decompress(buf) {
|
|
13
|
+
return Buffer.from((await this.instantiate()).decompress(buf));
|
|
22
14
|
}
|
|
23
15
|
}
|
|
24
16
|
exports.Brotli = Brotli;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"brotli.helper.js","sourceRoot":"","sources":["../../../src/common/core/helpers/brotli.helper.ts"],"names":[],"mappings":";;;AAEA,MAAa,MAAM;
|
|
1
|
+
{"version":3,"file":"brotli.helper.js","sourceRoot":"","sources":["../../../src/common/core/helpers/brotli.helper.ts"],"names":[],"mappings":";;;AAEA,MAAa,MAAM;IAEP,MAAM,CAAC,KAAK,CAAC,WAAW;QAChC,iEAAiE;QACjE,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,CAAC,MAAM,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IACvE,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAgC,EAAE,UAAkB,CAAC;QACzE,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;IAC5E,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,GAAgC;QACtD,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;IACjE,CAAC;CACF;AAdD,wBAcC"}
|