@keyv/compress-gzip 6.0.0-alpha.2 → 6.0.0-alpha.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 +5 -18
- package/dist/index.d.cts +3 -15
- package/dist/index.d.ts +3 -15
- package/dist/index.js +5 -18
- package/package.json +4 -5
package/dist/index.cjs
CHANGED
|
@@ -24,34 +24,22 @@ __export(index_exports, {
|
|
|
24
24
|
default: () => index_default
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(index_exports);
|
|
27
|
-
var
|
|
27
|
+
var import_node_buffer = require("buffer");
|
|
28
28
|
var import_pako = require("pako");
|
|
29
29
|
var KeyvGzip = class {
|
|
30
30
|
opts;
|
|
31
31
|
constructor(options) {
|
|
32
32
|
this.opts = {
|
|
33
|
-
to: "string",
|
|
34
33
|
...options
|
|
35
34
|
};
|
|
36
35
|
}
|
|
37
36
|
async compress(value, options) {
|
|
38
|
-
|
|
37
|
+
const compressed = (0, import_pako.deflate)(value, options || this.opts);
|
|
38
|
+
return import_node_buffer.Buffer.from(compressed).toString("base64");
|
|
39
39
|
}
|
|
40
40
|
async decompress(value, options) {
|
|
41
|
-
|
|
42
|
-
|
|
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 };
|
|
41
|
+
const buffer = import_node_buffer.Buffer.from(value, "base64");
|
|
42
|
+
return (0, import_pako.inflate)(buffer, { ...options || this.opts, to: "string" });
|
|
55
43
|
}
|
|
56
44
|
};
|
|
57
45
|
var index_default = KeyvGzip;
|
|
@@ -59,4 +47,3 @@ var index_default = KeyvGzip;
|
|
|
59
47
|
0 && (module.exports = {
|
|
60
48
|
KeyvGzip
|
|
61
49
|
});
|
|
62
|
-
/* v8 ignore next -- @preserve */
|
package/dist/index.d.cts
CHANGED
|
@@ -1,28 +1,16 @@
|
|
|
1
|
-
import { DeflateFunctionOptions, InflateOptions
|
|
1
|
+
import { DeflateFunctionOptions, InflateOptions } from 'pako';
|
|
2
2
|
|
|
3
3
|
type PakoDeflateOptions = DeflateFunctionOptions;
|
|
4
4
|
type PakoInflateOptions = InflateOptions & {
|
|
5
5
|
to?: "string";
|
|
6
6
|
};
|
|
7
7
|
type Options = PakoDeflateOptions & PakoInflateOptions;
|
|
8
|
-
type Serialize = {
|
|
9
|
-
value: string | Data;
|
|
10
|
-
expires?: number;
|
|
11
|
-
};
|
|
12
8
|
|
|
13
9
|
declare class KeyvGzip {
|
|
14
10
|
opts: Options;
|
|
15
11
|
constructor(options?: Options);
|
|
16
|
-
compress(value: pako.Data | string, options?: Options): Promise<
|
|
17
|
-
decompress(value:
|
|
18
|
-
serialize({ value, expires }: Serialize): Promise<string>;
|
|
19
|
-
deserialize(data: string): Promise<{
|
|
20
|
-
value: Uint8Array<ArrayBuffer>;
|
|
21
|
-
expires: number | undefined;
|
|
22
|
-
} | {
|
|
23
|
-
value: undefined;
|
|
24
|
-
expires: undefined;
|
|
25
|
-
}>;
|
|
12
|
+
compress(value: pako.Data | string, options?: Options): Promise<string>;
|
|
13
|
+
decompress(value: string, options?: Options): Promise<string>;
|
|
26
14
|
}
|
|
27
15
|
|
|
28
16
|
export { KeyvGzip, KeyvGzip as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,28 +1,16 @@
|
|
|
1
|
-
import { DeflateFunctionOptions, InflateOptions
|
|
1
|
+
import { DeflateFunctionOptions, InflateOptions } from 'pako';
|
|
2
2
|
|
|
3
3
|
type PakoDeflateOptions = DeflateFunctionOptions;
|
|
4
4
|
type PakoInflateOptions = InflateOptions & {
|
|
5
5
|
to?: "string";
|
|
6
6
|
};
|
|
7
7
|
type Options = PakoDeflateOptions & PakoInflateOptions;
|
|
8
|
-
type Serialize = {
|
|
9
|
-
value: string | Data;
|
|
10
|
-
expires?: number;
|
|
11
|
-
};
|
|
12
8
|
|
|
13
9
|
declare class KeyvGzip {
|
|
14
10
|
opts: Options;
|
|
15
11
|
constructor(options?: Options);
|
|
16
|
-
compress(value: pako.Data | string, options?: Options): Promise<
|
|
17
|
-
decompress(value:
|
|
18
|
-
serialize({ value, expires }: Serialize): Promise<string>;
|
|
19
|
-
deserialize(data: string): Promise<{
|
|
20
|
-
value: Uint8Array<ArrayBuffer>;
|
|
21
|
-
expires: number | undefined;
|
|
22
|
-
} | {
|
|
23
|
-
value: undefined;
|
|
24
|
-
expires: undefined;
|
|
25
|
-
}>;
|
|
12
|
+
compress(value: pako.Data | string, options?: Options): Promise<string>;
|
|
13
|
+
decompress(value: string, options?: Options): Promise<string>;
|
|
26
14
|
}
|
|
27
15
|
|
|
28
16
|
export { KeyvGzip, KeyvGzip as default };
|
package/dist/index.js
CHANGED
|
@@ -1,32 +1,20 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import {
|
|
2
|
+
import { Buffer } from "buffer";
|
|
3
3
|
import { deflate, inflate } from "pako";
|
|
4
4
|
var KeyvGzip = class {
|
|
5
5
|
opts;
|
|
6
6
|
constructor(options) {
|
|
7
7
|
this.opts = {
|
|
8
|
-
to: "string",
|
|
9
8
|
...options
|
|
10
9
|
};
|
|
11
10
|
}
|
|
12
11
|
async compress(value, options) {
|
|
13
|
-
|
|
12
|
+
const compressed = deflate(value, options || this.opts);
|
|
13
|
+
return Buffer.from(compressed).toString("base64");
|
|
14
14
|
}
|
|
15
15
|
async decompress(value, options) {
|
|
16
|
-
|
|
17
|
-
|
|
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 };
|
|
16
|
+
const buffer = Buffer.from(value, "base64");
|
|
17
|
+
return inflate(buffer, { ...options || this.opts, to: "string" });
|
|
30
18
|
}
|
|
31
19
|
};
|
|
32
20
|
var index_default = KeyvGzip;
|
|
@@ -34,4 +22,3 @@ export {
|
|
|
34
22
|
KeyvGzip,
|
|
35
23
|
index_default as default
|
|
36
24
|
};
|
|
37
|
-
/* v8 ignore next -- @preserve */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keyv/compress-gzip",
|
|
3
|
-
"version": "6.0.0-alpha.
|
|
3
|
+
"version": "6.0.0-alpha.3",
|
|
4
4
|
"description": "gzip compression for keyv",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -42,11 +42,10 @@
|
|
|
42
42
|
"homepage": "https://github.com/jaredwray/keyv",
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@types/pako": "^2.0.4",
|
|
45
|
-
"pako": "^2.1.0"
|
|
46
|
-
"@keyv/serialize": "^6.0.0-alpha.2"
|
|
45
|
+
"pako": "^2.1.0"
|
|
47
46
|
},
|
|
48
47
|
"peerDependencies": {
|
|
49
|
-
"keyv": "^6.0.0-alpha.
|
|
48
|
+
"keyv": "^6.0.0-alpha.3"
|
|
50
49
|
},
|
|
51
50
|
"devDependencies": {
|
|
52
51
|
"@biomejs/biome": "^2.3.13",
|
|
@@ -54,7 +53,7 @@
|
|
|
54
53
|
"rimraf": "^6.1.2",
|
|
55
54
|
"tsd": "^0.33.0",
|
|
56
55
|
"vitest": "^4.0.18",
|
|
57
|
-
"@keyv/test-suite": "^6.0.0-alpha.
|
|
56
|
+
"@keyv/test-suite": "^6.0.0-alpha.3"
|
|
58
57
|
},
|
|
59
58
|
"tsd": {
|
|
60
59
|
"directory": "test"
|