@keyv/compress-gzip 2.0.0 → 2.0.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.
package/dist/index.cjs ADDED
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
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
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ KeyvGzip: () => KeyvGzip,
34
+ default: () => src_default
35
+ });
36
+ module.exports = __toCommonJS(src_exports);
37
+ var import_pako = __toESM(require("pako"), 1);
38
+ var import_serialize = require("@keyv/serialize");
39
+ var KeyvGzip = class {
40
+ opts;
41
+ constructor(options) {
42
+ this.opts = {
43
+ to: "string",
44
+ ...options
45
+ };
46
+ }
47
+ async compress(value, options) {
48
+ return import_pako.default.deflate(value, options || this.opts);
49
+ }
50
+ async decompress(value, options) {
51
+ if (options) {
52
+ options.to = "string";
53
+ }
54
+ return import_pako.default.inflate(value, options || this.opts);
55
+ }
56
+ async serialize({ value, expires }) {
57
+ return (0, import_serialize.defaultSerialize)({ value: await this.compress(value), expires });
58
+ }
59
+ async deserialize(data) {
60
+ const { value, expires } = (0, import_serialize.defaultDeserialize)(data);
61
+ return { value: await this.decompress(value), expires };
62
+ }
63
+ };
64
+ var src_default = KeyvGzip;
65
+ // Annotate the CommonJS export names for ESM import in node:
66
+ 0 && (module.exports = {
67
+ KeyvGzip
68
+ });
@@ -1,5 +1,15 @@
1
- import pako from 'pako';
2
- import type { Options, Serialize } from './types.js';
1
+ import pako, { Data, DeflateFunctionOptions, InflateOptions } from 'pako';
2
+
3
+ type PakoDeflateOptions = DeflateFunctionOptions;
4
+ type PakoInflateOptions = InflateOptions & {
5
+ to?: 'string';
6
+ };
7
+ type Options = PakoDeflateOptions & PakoInflateOptions;
8
+ type Serialize = {
9
+ value: string | Data;
10
+ expires?: number;
11
+ };
12
+
3
13
  declare class KeyvGzip {
4
14
  opts: Options;
5
15
  constructor(options?: Options);
@@ -11,4 +21,5 @@ declare class KeyvGzip {
11
21
  expires: number | undefined;
12
22
  }>;
13
23
  }
14
- export default KeyvGzip;
24
+
25
+ export { KeyvGzip, KeyvGzip as default };
@@ -1,5 +1,15 @@
1
- import pako from 'pako';
2
- import type { Options, Serialize } from './types.js';
1
+ import pako, { Data, DeflateFunctionOptions, InflateOptions } from 'pako';
2
+
3
+ type PakoDeflateOptions = DeflateFunctionOptions;
4
+ type PakoInflateOptions = InflateOptions & {
5
+ to?: 'string';
6
+ };
7
+ type Options = PakoDeflateOptions & PakoInflateOptions;
8
+ type Serialize = {
9
+ value: string | Data;
10
+ expires?: number;
11
+ };
12
+
3
13
  declare class KeyvGzip {
4
14
  opts: Options;
5
15
  constructor(options?: Options);
@@ -11,4 +21,5 @@ declare class KeyvGzip {
11
21
  expires: number | undefined;
12
22
  }>;
13
23
  }
14
- export default KeyvGzip;
24
+
25
+ export { KeyvGzip, KeyvGzip as default };
package/dist/index.js ADDED
@@ -0,0 +1,33 @@
1
+ // src/index.ts
2
+ import pako from "pako";
3
+ import { defaultSerialize, defaultDeserialize } from "@keyv/serialize";
4
+ var KeyvGzip = class {
5
+ opts;
6
+ constructor(options) {
7
+ this.opts = {
8
+ to: "string",
9
+ ...options
10
+ };
11
+ }
12
+ async compress(value, options) {
13
+ return pako.deflate(value, options || this.opts);
14
+ }
15
+ async decompress(value, options) {
16
+ if (options) {
17
+ options.to = "string";
18
+ }
19
+ return pako.inflate(value, options || this.opts);
20
+ }
21
+ async serialize({ value, expires }) {
22
+ return defaultSerialize({ value: await this.compress(value), expires });
23
+ }
24
+ async deserialize(data) {
25
+ const { value, expires } = defaultDeserialize(data);
26
+ return { value: await this.decompress(value), expires };
27
+ }
28
+ };
29
+ var src_default = KeyvGzip;
30
+ export {
31
+ KeyvGzip,
32
+ src_default as default
33
+ };
package/package.json CHANGED
@@ -1,18 +1,19 @@
1
1
  {
2
2
  "name": "@keyv/compress-gzip",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "gzip compression for keyv",
5
- "main": "dist/cjs/index.js",
6
- "module": "dist/esm/index.js",
7
- "types": "dist/esm/index.d.ts",
5
+ "type": "module",
6
+ "main": "dist/index.cjs",
7
+ "module": "dist/index.js",
8
+ "types": "dist/index.d.ts",
8
9
  "exports": {
9
10
  ".": {
10
- "require": "./dist/cjs/index.js",
11
- "import": "./dist/esm/index.js"
11
+ "require": "./dist/index.cjs",
12
+ "import": "./dist/index.js"
12
13
  }
13
14
  },
14
15
  "scripts": {
15
- "build": "rm -rf dist && tsc --project tsconfig.cjs.json && tsc --project tsconfig.esm.json",
16
+ "build": "rm -rf dist && tsup src/index.ts --format cjs,esm --dts --clean",
16
17
  "prepare": "yarn build",
17
18
  "test": "xo --fix && vitest run --coverage",
18
19
  "test:ci": "xo && vitest --run --sequence.setupFiles=list",
@@ -20,6 +21,7 @@
20
21
  },
21
22
  "xo": {
22
23
  "rules": {
24
+ "import/no-named-as-default": "off",
23
25
  "import/extensions": "off",
24
26
  "@typescript-eslint/prefer-nullish-coalescing": "off",
25
27
  "@typescript-eslint/no-unsafe-argument": "off",
package/dist/cjs/index.js DELETED
@@ -1,34 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const pako_1 = __importDefault(require("pako"));
7
- const serialize_1 = require("@keyv/serialize");
8
- class KeyvGzip {
9
- opts;
10
- constructor(options) {
11
- this.opts = {
12
- to: 'string',
13
- ...options,
14
- };
15
- }
16
- async compress(value, options) {
17
- return pako_1.default.deflate(value, options || this.opts);
18
- }
19
- async decompress(value, options) {
20
- if (options) {
21
- options.to = 'string';
22
- }
23
- return pako_1.default.inflate(value, options || this.opts);
24
- }
25
- async serialize({ value, expires }) {
26
- return (0, serialize_1.defaultSerialize)({ value: await this.compress(value), expires });
27
- }
28
- async deserialize(data) {
29
- const { value, expires } = (0, serialize_1.defaultDeserialize)(data);
30
- return { value: await this.decompress(value), expires };
31
- }
32
- }
33
- exports.default = KeyvGzip;
34
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;AAAA,gDAAwB;AACxB,+CAAqE;AAGrE,MAAM,QAAQ;IACb,IAAI,CAAU;IACd,YAAY,OAAiB;QAC5B,IAAI,CAAC,IAAI,GAAG;YACX,EAAE,EAAE,QAAQ;YACZ,GAAG,OAAO;SACV,CAAC;IACH,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,KAAyB,EAAE,OAAiB;QAC1D,OAAO,cAAI,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;IAClD,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,KAAgB,EAAE,OAAiB;QACnD,IAAI,OAAO,EAAE,CAAC;YACb,OAAO,CAAC,EAAE,GAAG,QAAQ,CAAC;QACvB,CAAC;QAED,OAAO,cAAI,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;IAClD,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,EAAC,KAAK,EAAE,OAAO,EAAY;QAC1C,OAAO,IAAA,4BAAgB,EAAC,EAAC,KAAK,EAAE,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,EAAC,CAAC,CAAC;IACvE,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,IAAY;QAC7B,MAAM,EAAC,KAAK,EAAE,OAAO,EAAC,GAAc,IAAA,8BAAkB,EAAC,IAAI,CAAC,CAAC;QAC7D,OAAO,EAAC,KAAK,EAAE,MAAM,IAAI,CAAC,UAAU,CAAC,KAAkB,CAAC,EAAE,OAAO,EAAC,CAAC;IACpE,CAAC;CACD;AAED,kBAAe,QAAQ,CAAC"}
@@ -1,11 +0,0 @@
1
- import type { Data, DeflateFunctionOptions, InflateOptions } from 'pako';
2
- type PakoDeflateOptions = DeflateFunctionOptions;
3
- type PakoInflateOptions = InflateOptions & {
4
- to?: 'string';
5
- };
6
- export type Options = PakoDeflateOptions & PakoInflateOptions;
7
- export type Serialize = {
8
- value: string | Data;
9
- expires?: number;
10
- };
11
- export {};
package/dist/cjs/types.js DELETED
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
package/dist/esm/index.js DELETED
@@ -1,29 +0,0 @@
1
- import pako from 'pako';
2
- import { defaultSerialize, defaultDeserialize } from '@keyv/serialize';
3
- class KeyvGzip {
4
- opts;
5
- constructor(options) {
6
- this.opts = {
7
- to: 'string',
8
- ...options,
9
- };
10
- }
11
- async compress(value, options) {
12
- return pako.deflate(value, options || this.opts);
13
- }
14
- async decompress(value, options) {
15
- if (options) {
16
- options.to = 'string';
17
- }
18
- return pako.inflate(value, options || this.opts);
19
- }
20
- async serialize({ value, expires }) {
21
- return defaultSerialize({ value: await this.compress(value), expires });
22
- }
23
- async deserialize(data) {
24
- const { value, expires } = defaultDeserialize(data);
25
- return { value: await this.decompress(value), expires };
26
- }
27
- }
28
- export default KeyvGzip;
29
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAC,gBAAgB,EAAE,kBAAkB,EAAC,MAAM,iBAAiB,CAAC;AAGrE,MAAM,QAAQ;IACb,IAAI,CAAU;IACd,YAAY,OAAiB;QAC5B,IAAI,CAAC,IAAI,GAAG;YACX,EAAE,EAAE,QAAQ;YACZ,GAAG,OAAO;SACV,CAAC;IACH,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,KAAyB,EAAE,OAAiB;QAC1D,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;IAClD,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,KAAgB,EAAE,OAAiB;QACnD,IAAI,OAAO,EAAE,CAAC;YACb,OAAO,CAAC,EAAE,GAAG,QAAQ,CAAC;QACvB,CAAC;QAED,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;IAClD,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,EAAC,KAAK,EAAE,OAAO,EAAY;QAC1C,OAAO,gBAAgB,CAAC,EAAC,KAAK,EAAE,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,EAAC,CAAC,CAAC;IACvE,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,IAAY;QAC7B,MAAM,EAAC,KAAK,EAAE,OAAO,EAAC,GAAc,kBAAkB,CAAC,IAAI,CAAC,CAAC;QAC7D,OAAO,EAAC,KAAK,EAAE,MAAM,IAAI,CAAC,UAAU,CAAC,KAAkB,CAAC,EAAE,OAAO,EAAC,CAAC;IACpE,CAAC;CACD;AAED,eAAe,QAAQ,CAAC"}
@@ -1,11 +0,0 @@
1
- import type { Data, DeflateFunctionOptions, InflateOptions } from 'pako';
2
- type PakoDeflateOptions = DeflateFunctionOptions;
3
- type PakoInflateOptions = InflateOptions & {
4
- to?: 'string';
5
- };
6
- export type Options = PakoDeflateOptions & PakoInflateOptions;
7
- export type Serialize = {
8
- value: string | Data;
9
- expires?: number;
10
- };
11
- export {};
package/dist/esm/types.js DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}