@keyv/compress-gzip 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 +8 -15
- package/dist/index.d.cts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +8 -5
- package/package.json +1 -1
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,14 +15,6 @@ 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
|
|
@@ -34,7 +24,7 @@ __export(src_exports, {
|
|
|
34
24
|
default: () => src_default
|
|
35
25
|
});
|
|
36
26
|
module.exports = __toCommonJS(src_exports);
|
|
37
|
-
var import_pako =
|
|
27
|
+
var import_pako = require("pako");
|
|
38
28
|
var import_serialize = require("@keyv/serialize");
|
|
39
29
|
var KeyvGzip = class {
|
|
40
30
|
opts;
|
|
@@ -45,20 +35,23 @@ var KeyvGzip = class {
|
|
|
45
35
|
};
|
|
46
36
|
}
|
|
47
37
|
async compress(value, options) {
|
|
48
|
-
return import_pako.
|
|
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.
|
|
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
|
-
|
|
61
|
-
|
|
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
57
|
var src_default = KeyvGzip;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Data, DeflateFunctionOptions, InflateOptions } from 'pako';
|
|
2
2
|
|
|
3
3
|
type PakoDeflateOptions = DeflateFunctionOptions;
|
|
4
4
|
type PakoInflateOptions = InflateOptions & {
|
|
@@ -19,6 +19,9 @@ declare class KeyvGzip {
|
|
|
19
19
|
deserialize(data: string): Promise<{
|
|
20
20
|
value: Uint8Array;
|
|
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
|
|
1
|
+
import { Data, DeflateFunctionOptions, InflateOptions } from 'pako';
|
|
2
2
|
|
|
3
3
|
type PakoDeflateOptions = DeflateFunctionOptions;
|
|
4
4
|
type PakoInflateOptions = InflateOptions & {
|
|
@@ -19,6 +19,9 @@ declare class KeyvGzip {
|
|
|
19
19
|
deserialize(data: string): Promise<{
|
|
20
20
|
value: Uint8Array;
|
|
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
|
|
2
|
+
import { inflate, deflate } from "pako";
|
|
3
3
|
import { defaultSerialize, defaultDeserialize } from "@keyv/serialize";
|
|
4
4
|
var KeyvGzip = class {
|
|
5
5
|
opts;
|
|
@@ -10,20 +10,23 @@ var KeyvGzip = class {
|
|
|
10
10
|
};
|
|
11
11
|
}
|
|
12
12
|
async compress(value, options) {
|
|
13
|
-
return
|
|
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
|
|
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
|
-
|
|
26
|
-
|
|
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
32
|
var src_default = KeyvGzip;
|