@keyv/compress-gzip 2.0.0 → 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 ADDED
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ KeyvGzip: () => KeyvGzip,
24
+ default: () => src_default
25
+ });
26
+ module.exports = __toCommonJS(src_exports);
27
+ var import_pako = require("pako");
28
+ var import_serialize = require("@keyv/serialize");
29
+ var KeyvGzip = class {
30
+ opts;
31
+ constructor(options) {
32
+ this.opts = {
33
+ to: "string",
34
+ ...options
35
+ };
36
+ }
37
+ async compress(value, options) {
38
+ return (0, import_pako.deflate)(value, options || this.opts);
39
+ }
40
+ async decompress(value, options) {
41
+ if (options) {
42
+ options.to = "string";
43
+ }
44
+ return (0, import_pako.inflate)(value, options || this.opts);
45
+ }
46
+ async serialize({ value, expires }) {
47
+ return (0, import_serialize.defaultSerialize)({ value: await this.compress(value), expires });
48
+ }
49
+ async deserialize(data) {
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 };
55
+ }
56
+ };
57
+ var src_default = KeyvGzip;
58
+ // Annotate the CommonJS export names for ESM import in node:
59
+ 0 && (module.exports = {
60
+ KeyvGzip
61
+ });
@@ -0,0 +1,28 @@
1
+ import { 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
+
13
+ declare class KeyvGzip {
14
+ opts: Options;
15
+ constructor(options?: Options);
16
+ compress(value: pako.Data | string, options?: Options): Promise<Uint8Array>;
17
+ decompress(value: pako.Data, options?: Options): Promise<Uint8Array>;
18
+ serialize({ value, expires }: Serialize): Promise<string>;
19
+ deserialize(data: string): Promise<{
20
+ value: Uint8Array;
21
+ expires: number | undefined;
22
+ } | {
23
+ value: undefined;
24
+ expires: undefined;
25
+ }>;
26
+ }
27
+
28
+ export { KeyvGzip, KeyvGzip as default };
@@ -0,0 +1,28 @@
1
+ import { 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
+
13
+ declare class KeyvGzip {
14
+ opts: Options;
15
+ constructor(options?: Options);
16
+ compress(value: pako.Data | string, options?: Options): Promise<Uint8Array>;
17
+ decompress(value: pako.Data, options?: Options): Promise<Uint8Array>;
18
+ serialize({ value, expires }: Serialize): Promise<string>;
19
+ deserialize(data: string): Promise<{
20
+ value: Uint8Array;
21
+ expires: number | undefined;
22
+ } | {
23
+ value: undefined;
24
+ expires: undefined;
25
+ }>;
26
+ }
27
+
28
+ export { KeyvGzip, KeyvGzip as default };
package/dist/index.js ADDED
@@ -0,0 +1,36 @@
1
+ // src/index.ts
2
+ import { inflate, deflate } 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 deflate(value, options || this.opts);
14
+ }
15
+ async decompress(value, options) {
16
+ if (options) {
17
+ options.to = "string";
18
+ }
19
+ return 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
+ 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 };
30
+ }
31
+ };
32
+ var src_default = KeyvGzip;
33
+ export {
34
+ KeyvGzip,
35
+ src_default as default
36
+ };
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.2",
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",
@@ -1,14 +0,0 @@
1
- import pako from 'pako';
2
- import type { Options, Serialize } from './types.js';
3
- declare class KeyvGzip {
4
- opts: Options;
5
- constructor(options?: Options);
6
- compress(value: pako.Data | string, options?: Options): Promise<Uint8Array>;
7
- decompress(value: pako.Data, options?: Options): Promise<Uint8Array>;
8
- serialize({ value, expires }: Serialize): Promise<string>;
9
- deserialize(data: string): Promise<{
10
- value: Uint8Array;
11
- expires: number | undefined;
12
- }>;
13
- }
14
- export default KeyvGzip;
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":""}
@@ -1,14 +0,0 @@
1
- import pako from 'pako';
2
- import type { Options, Serialize } from './types.js';
3
- declare class KeyvGzip {
4
- opts: Options;
5
- constructor(options?: Options);
6
- compress(value: pako.Data | string, options?: Options): Promise<Uint8Array>;
7
- decompress(value: pako.Data, options?: Options): Promise<Uint8Array>;
8
- serialize({ value, expires }: Serialize): Promise<string>;
9
- deserialize(data: string): Promise<{
10
- value: Uint8Array;
11
- expires: number | undefined;
12
- }>;
13
- }
14
- export default KeyvGzip;
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":""}