@keyv/compress-brotli 2.0.1 → 2.0.2
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/dist/index.cjs +9 -3
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +9 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -45,14 +45,20 @@ var KeyvBrotli = class {
|
|
|
45
45
|
return this.brotli.compress(value, options);
|
|
46
46
|
}
|
|
47
47
|
async decompress(data, options) {
|
|
48
|
-
|
|
48
|
+
if (data) {
|
|
49
|
+
return await this.brotli.decompress(data, options);
|
|
50
|
+
}
|
|
51
|
+
return void 0;
|
|
49
52
|
}
|
|
50
53
|
async serialize({ value, expires }) {
|
|
51
54
|
return (0, import_serialize.defaultSerialize)({ value: await this.compress(value), expires });
|
|
52
55
|
}
|
|
53
56
|
async deserialize(data) {
|
|
54
|
-
|
|
55
|
-
|
|
57
|
+
if (data) {
|
|
58
|
+
const { value, expires } = (0, import_serialize.defaultDeserialize)(data);
|
|
59
|
+
return { value: await this.decompress(value), expires };
|
|
60
|
+
}
|
|
61
|
+
return { value: void 0, expires: void 0 };
|
|
56
62
|
}
|
|
57
63
|
};
|
|
58
64
|
var src_default = KeyvBrotli;
|
package/dist/index.d.cts
CHANGED
|
@@ -3,7 +3,7 @@ import { CompressCallback, InputType, BrotliOptions } from 'node:zlib';
|
|
|
3
3
|
type CompressResult = Promise<Parameters<CompressCallback>[1]>;
|
|
4
4
|
type SerializeResult = string;
|
|
5
5
|
type Serialize = {
|
|
6
|
-
value
|
|
6
|
+
value?: InputType;
|
|
7
7
|
expires?: number;
|
|
8
8
|
};
|
|
9
9
|
interface Options {
|
|
@@ -19,9 +19,9 @@ declare class KeyvBrotli {
|
|
|
19
19
|
private readonly brotli;
|
|
20
20
|
constructor(options?: Options);
|
|
21
21
|
compress(value: any, options?: BrotliOptions): CompressResult;
|
|
22
|
-
decompress<T>(data
|
|
22
|
+
decompress<T>(data?: InputType, options?: BrotliOptions): Promise<T>;
|
|
23
23
|
serialize({ value, expires }: Serialize): Promise<SerializeResult>;
|
|
24
|
-
deserialize(data
|
|
24
|
+
deserialize(data?: CompressResult): Promise<Serialize>;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
export { KeyvBrotli, KeyvBrotli as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { CompressCallback, InputType, BrotliOptions } from 'node:zlib';
|
|
|
3
3
|
type CompressResult = Promise<Parameters<CompressCallback>[1]>;
|
|
4
4
|
type SerializeResult = string;
|
|
5
5
|
type Serialize = {
|
|
6
|
-
value
|
|
6
|
+
value?: InputType;
|
|
7
7
|
expires?: number;
|
|
8
8
|
};
|
|
9
9
|
interface Options {
|
|
@@ -19,9 +19,9 @@ declare class KeyvBrotli {
|
|
|
19
19
|
private readonly brotli;
|
|
20
20
|
constructor(options?: Options);
|
|
21
21
|
compress(value: any, options?: BrotliOptions): CompressResult;
|
|
22
|
-
decompress<T>(data
|
|
22
|
+
decompress<T>(data?: InputType, options?: BrotliOptions): Promise<T>;
|
|
23
23
|
serialize({ value, expires }: Serialize): Promise<SerializeResult>;
|
|
24
|
-
deserialize(data
|
|
24
|
+
deserialize(data?: CompressResult): Promise<Serialize>;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
export { KeyvBrotli, KeyvBrotli as default };
|
package/dist/index.js
CHANGED
|
@@ -10,14 +10,20 @@ var KeyvBrotli = class {
|
|
|
10
10
|
return this.brotli.compress(value, options);
|
|
11
11
|
}
|
|
12
12
|
async decompress(data, options) {
|
|
13
|
-
|
|
13
|
+
if (data) {
|
|
14
|
+
return await this.brotli.decompress(data, options);
|
|
15
|
+
}
|
|
16
|
+
return void 0;
|
|
14
17
|
}
|
|
15
18
|
async serialize({ value, expires }) {
|
|
16
19
|
return defaultSerialize({ value: await this.compress(value), expires });
|
|
17
20
|
}
|
|
18
21
|
async deserialize(data) {
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
if (data) {
|
|
23
|
+
const { value, expires } = defaultDeserialize(data);
|
|
24
|
+
return { value: await this.decompress(value), expires };
|
|
25
|
+
}
|
|
26
|
+
return { value: void 0, expires: void 0 };
|
|
21
27
|
}
|
|
22
28
|
};
|
|
23
29
|
var src_default = KeyvBrotli;
|