@keyv/compress-gzip 1.0.1 → 1.1.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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # @keyv/tiered [<img width="100" align="right" src="https://rawgit.com/lukechilds/keyv/master/media/logo.svg" alt="keyv">](https://github.com/lukechilds/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.0.1",
3
+ "version": "1.1.1",
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"
@@ -41,6 +51,7 @@
41
51
  "pako": "^2.0.4"
42
52
  },
43
53
  "devDependencies": {
54
+ "@keyv/test-suite": "*",
44
55
  "@types/keyv": "^3.1.4",
45
56
  "ava": "^4.2.0",
46
57
  "keyv": "*",
package/src/index.d.ts CHANGED
@@ -1,19 +1,10 @@
1
- import {EventEmitter} from 'node:events';
2
- import {Store, StoredData} from 'keyv';
3
-
4
- declare class KeyvGzip extends EventEmitter {
5
- ttlSupport: any;
1
+ declare class KeyvGzip {
6
2
  opts: any;
7
- constructor(options?: string | KeyvGzip.Options);
8
- compress(value: Value);
9
- decompress(value: Value);
10
- }
11
-
12
- declare namespace KeyvGzip {
13
- interface Options {
14
- compress: (...args: any[]) => void;
15
- decompress: (...args: any[]) => void;
16
- }
3
+ constructor(options?);
4
+ async compress(value: any);
5
+ async decompress(value: any);
6
+ async serialize(value: any);
7
+ async deserialize(value: any);
17
8
  }
18
9
 
19
10
  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
- this.opts.compress = pako.deflate;
12
- this.opts.decompress = pako.inflate;
13
- this.opts.serialize = async ({value, expires}) => JSONB.stringify({value: await this.opts.compress(value, this.opts), expires});
14
- this.opts.deserialize = async data => {
15
- const {value, expires} = JSONB.parse(data);
16
- const value_ = await this.opts.decompress(value, this.opts);
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
- compress(value, options) {
22
- return this.opts.compress(value, {...this.opts, ...options});
20
+ async serialize({value, expires}) {
21
+ return JSONB.stringify({value: await this.compress(value, this.opts), expires});
23
22
  }
24
23
 
25
- decompress(value, options) {
26
- return this.opts.decompress(value, {...this.opts, ...options});
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