@keyv/compress-gzip 1.0.1 → 1.1.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/README.md +1 -1
- package/package.json +18 -7
- package/src/index.d.ts +8 -14
- package/src/index.js +12 -12
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @keyv/
|
|
1
|
+
# @keyv/compress-gzip [<img width="100" align="right" src="https://jaredwray.com/images/keyv.svg" alt="keyv">](https://github.com/jaredwray/keyv)
|
|
2
2
|
|
|
3
3
|
> Gzip compression for Keyv
|
|
4
4
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keyv/compress-gzip",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "gzip compression for keyv",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -14,6 +14,16 @@
|
|
|
14
14
|
"unicorn/prefer-node-protocol": 0
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
|
+
"ava": {
|
|
18
|
+
"require": [
|
|
19
|
+
"requirable",
|
|
20
|
+
"ts-node/register"
|
|
21
|
+
],
|
|
22
|
+
"extensions": [
|
|
23
|
+
"js",
|
|
24
|
+
"ts"
|
|
25
|
+
]
|
|
26
|
+
},
|
|
17
27
|
"repository": {
|
|
18
28
|
"type": "git",
|
|
19
29
|
"url": "git+https://github.com/jaredwray/keyv.git"
|
|
@@ -37,20 +47,21 @@
|
|
|
37
47
|
},
|
|
38
48
|
"homepage": "https://github.com/jaredwray/keyv",
|
|
39
49
|
"dependencies": {
|
|
50
|
+
"@types/pako": "^2.0.0",
|
|
40
51
|
"json-buffer": "^3.0.1",
|
|
41
52
|
"pako": "^2.0.4"
|
|
42
53
|
},
|
|
43
54
|
"devDependencies": {
|
|
55
|
+
"@keyv/test-suite": "*",
|
|
44
56
|
"@types/keyv": "^3.1.4",
|
|
45
|
-
"ava": "^
|
|
57
|
+
"ava": "^5.0.1",
|
|
46
58
|
"keyv": "*",
|
|
47
59
|
"nyc": "^15.1.0",
|
|
48
60
|
"requirable": "^1.0.5",
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"xo": "^0.48.0"
|
|
61
|
+
"ts-node": "^10.9.1",
|
|
62
|
+
"tsd": "^0.24.1",
|
|
63
|
+
"typescript": "^4.8.4",
|
|
64
|
+
"xo": "^0.52.4"
|
|
54
65
|
},
|
|
55
66
|
"tsd": {
|
|
56
67
|
"directory": "test"
|
package/src/index.d.ts
CHANGED
|
@@ -1,19 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {Store, StoredData} from 'keyv';
|
|
1
|
+
import type pako from 'pako';
|
|
3
2
|
|
|
4
|
-
declare class KeyvGzip
|
|
5
|
-
ttlSupport: any;
|
|
3
|
+
declare class KeyvGzip {
|
|
6
4
|
opts: any;
|
|
7
|
-
constructor(options?:
|
|
8
|
-
compress(value:
|
|
9
|
-
decompress(value:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
interface Options {
|
|
14
|
-
compress: (...args: any[]) => void;
|
|
15
|
-
decompress: (...args: any[]) => void;
|
|
16
|
-
}
|
|
5
|
+
constructor(options?: pako.DeflateFunctionOptions | pako.InflateFunctionOptions);
|
|
6
|
+
compress(value: pako.Data | string, options?: pako.DeflateFunctionOptions): Promise<Uint8Array>;
|
|
7
|
+
decompress(value: pako.Data, options?: pako.InflateFunctionOptions & {to: 'string'}): Promise<string>;
|
|
8
|
+
decompress(value: pako.Data, options?: pako.InflateFunctionOptions): Promise<Uint8Array>;
|
|
9
|
+
serialize(value: any): Promise<any>;
|
|
10
|
+
deserialize(value: any): Promise<any>;
|
|
17
11
|
}
|
|
18
12
|
|
|
19
13
|
export = KeyvGzip;
|
package/src/index.js
CHANGED
|
@@ -7,23 +7,23 @@ class KeyvGzip {
|
|
|
7
7
|
to: 'string',
|
|
8
8
|
...options,
|
|
9
9
|
};
|
|
10
|
+
}
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return {value: value_, expires};
|
|
18
|
-
};
|
|
12
|
+
async compress(value, options) {
|
|
13
|
+
return pako.deflate(value, options ? options : this.opts);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async decompress(value, options) {
|
|
17
|
+
return pako.inflate(value, options ? options : this.opts);
|
|
19
18
|
}
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
return this.
|
|
20
|
+
async serialize({value, expires}) {
|
|
21
|
+
return JSONB.stringify({value: await this.compress(value, this.opts), expires});
|
|
23
22
|
}
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
async deserialize(data) {
|
|
25
|
+
const {value, expires} = JSONB.parse(data);
|
|
26
|
+
return {value: await this.decompress(value, this.opts), expires};
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|