@keyv/compress-brotli 1.0.0 → 1.1.0
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 +3 -2
- package/src/index.d.ts +15 -10
- package/src/index.js +12 -16
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @keyv/
|
|
1
|
+
# @keyv/compress-brotli [<img width="100" align="right" src="https://jaredwray.com/images/keyv.svg" alt="keyv">](https://github.com/jaredwray/keyv)
|
|
2
2
|
|
|
3
3
|
> Brotli compression for Keyv
|
|
4
4
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keyv/compress-brotli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "brotli compression for keyv",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -59,8 +59,9 @@
|
|
|
59
59
|
"compress-brotli": "^1.3.8"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@
|
|
62
|
+
"@keyv/test-suite": "*",
|
|
63
63
|
"ava": "^4.2.0",
|
|
64
|
+
"json-buffer": "^3.0.1",
|
|
64
65
|
"keyv": "*",
|
|
65
66
|
"nyc": "^15.1.0",
|
|
66
67
|
"requirable": "^1.0.5",
|
package/src/index.d.ts
CHANGED
|
@@ -1,18 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import type {InputType, BrotliOptions, CompressCallback} from 'node:zlib';
|
|
2
|
+
import type Brotli, {CompressResult} from 'compress-brotli';
|
|
3
3
|
|
|
4
|
-
declare class KeyvBrotli
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
declare class KeyvBrotli {
|
|
5
|
+
brotli: Brotli;
|
|
6
|
+
constructor(options?: KeyvBrotli.Options);
|
|
7
|
+
async compress(value: InputType | number | boolean, options?: BrotliOptions);
|
|
8
|
+
async decompress(value: InputType | number | boolean, options?: BrotliOptions);
|
|
9
|
+
async serialize(value: any);
|
|
10
|
+
async deserialize(value: any);
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
declare namespace KeyvBrotli {
|
|
13
14
|
interface Options {
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
compressOptions?: BrotliOptions;
|
|
16
|
+
decompressOptions?: BrotliOptions;
|
|
17
|
+
enable?: boolean;
|
|
18
|
+
serialize?: any;
|
|
19
|
+
deserialize?: any;
|
|
20
|
+
iltorb?: any;
|
|
16
21
|
}
|
|
17
22
|
}
|
|
18
23
|
|
package/src/index.js
CHANGED
|
@@ -3,28 +3,24 @@ const compressBrotli = require('compress-brotli');
|
|
|
3
3
|
|
|
4
4
|
class KeyvBrotli {
|
|
5
5
|
constructor(options) {
|
|
6
|
-
this.
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
const {compress, decompress, serialize, deserialize} = compressBrotli(this.opts);
|
|
6
|
+
this.brotli = compressBrotli(options);
|
|
7
|
+
}
|
|
11
8
|
|
|
12
|
-
|
|
13
|
-
this.
|
|
9
|
+
async compress(value, options) {
|
|
10
|
+
return this.brotli.compress(value, options);
|
|
11
|
+
}
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
this.
|
|
17
|
-
const {value, expires} = deserialize(data);
|
|
18
|
-
return {value: await decompress(value), expires};
|
|
19
|
-
};
|
|
13
|
+
async decompress(data, options) {
|
|
14
|
+
return this.brotli.decompress(data, options);
|
|
20
15
|
}
|
|
21
16
|
|
|
22
|
-
|
|
23
|
-
return this.
|
|
17
|
+
async serialize({value, expires}) {
|
|
18
|
+
return this.brotli.serialize({value: await this.compress(value), expires});
|
|
24
19
|
}
|
|
25
20
|
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
async deserialize(data) {
|
|
22
|
+
const {value, expires} = this.brotli.deserialize(data);
|
|
23
|
+
return {value: await this.decompress(value), expires};
|
|
28
24
|
}
|
|
29
25
|
}
|
|
30
26
|
|