@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 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
- return await this.brotli.decompress(data, options);
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
- const { value, expires } = (0, import_serialize.defaultDeserialize)(data);
55
- return { value: await this.decompress(value), expires };
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: InputType;
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: InputType, options?: BrotliOptions): Promise<T>;
22
+ decompress<T>(data?: InputType, options?: BrotliOptions): Promise<T>;
23
23
  serialize({ value, expires }: Serialize): Promise<SerializeResult>;
24
- deserialize(data: CompressResult): Promise<Serialize>;
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: InputType;
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: InputType, options?: BrotliOptions): Promise<T>;
22
+ decompress<T>(data?: InputType, options?: BrotliOptions): Promise<T>;
23
23
  serialize({ value, expires }: Serialize): Promise<SerializeResult>;
24
- deserialize(data: CompressResult): Promise<Serialize>;
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
- return await this.brotli.decompress(data, options);
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
- const { value, expires } = defaultDeserialize(data);
20
- return { value: await this.decompress(value), expires };
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keyv/compress-brotli",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "brotli compression for keyv",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",