@keyv/compress-gzip 2.0.1 → 2.0.3

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
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,24 +15,16 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
 
30
20
  // src/index.ts
31
- var src_exports = {};
32
- __export(src_exports, {
21
+ var index_exports = {};
22
+ __export(index_exports, {
33
23
  KeyvGzip: () => KeyvGzip,
34
- default: () => src_default
24
+ default: () => index_default
35
25
  });
36
- module.exports = __toCommonJS(src_exports);
37
- var import_pako = __toESM(require("pako"), 1);
26
+ module.exports = __toCommonJS(index_exports);
27
+ var import_pako = require("pako");
38
28
  var import_serialize = require("@keyv/serialize");
39
29
  var KeyvGzip = class {
40
30
  opts;
@@ -45,23 +35,26 @@ var KeyvGzip = class {
45
35
  };
46
36
  }
47
37
  async compress(value, options) {
48
- return import_pako.default.deflate(value, options || this.opts);
38
+ return (0, import_pako.deflate)(value, options || this.opts);
49
39
  }
50
40
  async decompress(value, options) {
51
41
  if (options) {
52
42
  options.to = "string";
53
43
  }
54
- return import_pako.default.inflate(value, options || this.opts);
44
+ return (0, import_pako.inflate)(value, options || this.opts);
55
45
  }
56
46
  async serialize({ value, expires }) {
57
47
  return (0, import_serialize.defaultSerialize)({ value: await this.compress(value), expires });
58
48
  }
59
49
  async deserialize(data) {
60
- const { value, expires } = (0, import_serialize.defaultDeserialize)(data);
61
- return { value: await this.decompress(value), expires };
50
+ if (data) {
51
+ const { value, expires } = (0, import_serialize.defaultDeserialize)(data);
52
+ return { value: await this.decompress(value), expires };
53
+ }
54
+ return { value: void 0, expires: void 0 };
62
55
  }
63
56
  };
64
- var src_default = KeyvGzip;
57
+ var index_default = KeyvGzip;
65
58
  // Annotate the CommonJS export names for ESM import in node:
66
59
  0 && (module.exports = {
67
60
  KeyvGzip
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import pako, { Data, DeflateFunctionOptions, InflateOptions } from 'pako';
1
+ import { DeflateFunctionOptions, InflateOptions, Data } from 'pako';
2
2
 
3
3
  type PakoDeflateOptions = DeflateFunctionOptions;
4
4
  type PakoInflateOptions = InflateOptions & {
@@ -13,12 +13,15 @@ type Serialize = {
13
13
  declare class KeyvGzip {
14
14
  opts: Options;
15
15
  constructor(options?: Options);
16
- compress(value: pako.Data | string, options?: Options): Promise<Uint8Array>;
17
- decompress(value: pako.Data, options?: Options): Promise<Uint8Array>;
16
+ compress(value: pako.Data | string, options?: Options): Promise<Uint8Array<ArrayBufferLike>>;
17
+ decompress(value: pako.Data, options?: Options): Promise<Uint8Array<ArrayBufferLike>>;
18
18
  serialize({ value, expires }: Serialize): Promise<string>;
19
19
  deserialize(data: string): Promise<{
20
- value: Uint8Array;
20
+ value: Uint8Array<ArrayBufferLike>;
21
21
  expires: number | undefined;
22
+ } | {
23
+ value: undefined;
24
+ expires: undefined;
22
25
  }>;
23
26
  }
24
27
 
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import pako, { Data, DeflateFunctionOptions, InflateOptions } from 'pako';
1
+ import { DeflateFunctionOptions, InflateOptions, Data } from 'pako';
2
2
 
3
3
  type PakoDeflateOptions = DeflateFunctionOptions;
4
4
  type PakoInflateOptions = InflateOptions & {
@@ -13,12 +13,15 @@ type Serialize = {
13
13
  declare class KeyvGzip {
14
14
  opts: Options;
15
15
  constructor(options?: Options);
16
- compress(value: pako.Data | string, options?: Options): Promise<Uint8Array>;
17
- decompress(value: pako.Data, options?: Options): Promise<Uint8Array>;
16
+ compress(value: pako.Data | string, options?: Options): Promise<Uint8Array<ArrayBufferLike>>;
17
+ decompress(value: pako.Data, options?: Options): Promise<Uint8Array<ArrayBufferLike>>;
18
18
  serialize({ value, expires }: Serialize): Promise<string>;
19
19
  deserialize(data: string): Promise<{
20
- value: Uint8Array;
20
+ value: Uint8Array<ArrayBufferLike>;
21
21
  expires: number | undefined;
22
+ } | {
23
+ value: undefined;
24
+ expires: undefined;
22
25
  }>;
23
26
  }
24
27
 
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/index.ts
2
- import pako from "pako";
2
+ import { inflate, deflate } from "pako";
3
3
  import { defaultSerialize, defaultDeserialize } from "@keyv/serialize";
4
4
  var KeyvGzip = class {
5
5
  opts;
@@ -10,24 +10,27 @@ var KeyvGzip = class {
10
10
  };
11
11
  }
12
12
  async compress(value, options) {
13
- return pako.deflate(value, options || this.opts);
13
+ return deflate(value, options || this.opts);
14
14
  }
15
15
  async decompress(value, options) {
16
16
  if (options) {
17
17
  options.to = "string";
18
18
  }
19
- return pako.inflate(value, options || this.opts);
19
+ return inflate(value, options || this.opts);
20
20
  }
21
21
  async serialize({ value, expires }) {
22
22
  return defaultSerialize({ value: await this.compress(value), expires });
23
23
  }
24
24
  async deserialize(data) {
25
- const { value, expires } = defaultDeserialize(data);
26
- return { value: await this.decompress(value), expires };
25
+ if (data) {
26
+ const { value, expires } = defaultDeserialize(data);
27
+ return { value: await this.decompress(value), expires };
28
+ }
29
+ return { value: void 0, expires: void 0 };
27
30
  }
28
31
  };
29
- var src_default = KeyvGzip;
32
+ var index_default = KeyvGzip;
30
33
  export {
31
34
  KeyvGzip,
32
- src_default as default
35
+ index_default as default
33
36
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keyv/compress-gzip",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "gzip compression for keyv",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -12,13 +12,6 @@
12
12
  "import": "./dist/index.js"
13
13
  }
14
14
  },
15
- "scripts": {
16
- "build": "rm -rf dist && tsup src/index.ts --format cjs,esm --dts --clean",
17
- "prepare": "yarn build",
18
- "test": "xo --fix && vitest run --coverage",
19
- "test:ci": "xo && vitest --run --sequence.setupFiles=list",
20
- "clean": "rm -rf node_modules && rm -rf .nyc_output && rm -rf ./dist && rm -rf coverage.lcov && rm -rf ./test/testdb.sqlite"
21
- },
22
15
  "xo": {
23
16
  "rules": {
24
17
  "import/no-named-as-default": "off",
@@ -53,12 +46,16 @@
53
46
  "dependencies": {
54
47
  "@types/pako": "^2.0.3",
55
48
  "pako": "^2.1.0",
56
- "@keyv/serialize": "*"
49
+ "@keyv/serialize": "^1.0.3"
50
+ },
51
+ "peerDependencies": {
52
+ "keyv": "^5.3.3"
57
53
  },
58
54
  "devDependencies": {
59
- "@keyv/test-suite": "*",
60
- "tsd": "^0.31.1",
61
- "xo": "^0.59.3"
55
+ "rimraf": "^6.0.1",
56
+ "tsd": "^0.31.2",
57
+ "xo": "^0.60.0",
58
+ "@keyv/test-suite": "^2.0.6"
62
59
  },
63
60
  "tsd": {
64
61
  "directory": "test"
@@ -69,5 +66,11 @@
69
66
  "files": [
70
67
  "dist",
71
68
  "LICENSE"
72
- ]
73
- }
69
+ ],
70
+ "scripts": {
71
+ "build": "rimraf dist && tsup src/index.ts --format cjs,esm --dts --clean",
72
+ "test": "xo --fix && vitest run --coverage",
73
+ "test:ci": "xo && vitest --run --sequence.setupFiles=list",
74
+ "clean": "rimraf node_modules ./dist ./coverage ./test/testdb.sqlite"
75
+ }
76
+ }