@keyv/compress-brotli 1.1.2 → 1.1.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/README.md +1 -1
- package/dist/index.d.ts +12 -0
- package/dist/index.js +48 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +28 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +23 -22
- package/src/index.d.ts +0 -24
- package/src/index.js +0 -27
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @keyv/compress-brotli [<img width="100" align="right" src="https://jaredwray.com/images/keyv.svg" alt="keyv">](https://github.com/
|
|
1
|
+
# @keyv/compress-brotli [<img width="100" align="right" src="https://jaredwray.com/images/keyv.svg" alt="keyv">](https://github.com/jaredwra/keyv)
|
|
2
2
|
|
|
3
3
|
> Brotli compression for Keyv
|
|
4
4
|
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { BrotliOptions, InputType } from 'node:zlib';
|
|
3
|
+
import type { CompressResult, Options, SerializeResult, Serialize } from './types';
|
|
4
|
+
declare class KeyvBrotli {
|
|
5
|
+
private readonly brotli;
|
|
6
|
+
constructor(options?: Options);
|
|
7
|
+
compress(value: any, options?: BrotliOptions): CompressResult;
|
|
8
|
+
decompress<T>(data: InputType, options?: BrotliOptions): Promise<T>;
|
|
9
|
+
serialize({ value, expires }: Serialize): Promise<SerializeResult>;
|
|
10
|
+
deserialize(data: CompressResult): Promise<Serialize>;
|
|
11
|
+
}
|
|
12
|
+
export = KeyvBrotli;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
const compress_brotli_1 = __importDefault(require("compress-brotli"));
|
|
15
|
+
class KeyvBrotli {
|
|
16
|
+
constructor(options) {
|
|
17
|
+
this.brotli = (0, compress_brotli_1.default)(options);
|
|
18
|
+
}
|
|
19
|
+
compress(value, options) {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
return this.brotli.compress(value, options);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
decompress(data, options) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
return yield this.brotli.decompress(data, options);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
serialize({ value, expires }) {
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
const compressValue = yield this.compress(value);
|
|
32
|
+
// @ts-expect-error - `expires` is not part of the `SerializeResult` type
|
|
33
|
+
return this.brotli.serialize({ value: compressValue, expires });
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
deserialize(data) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
39
|
+
if (!data) {
|
|
40
|
+
return data;
|
|
41
|
+
}
|
|
42
|
+
const { value, expires } = this.brotli.deserialize(data);
|
|
43
|
+
return { value: yield this.decompress(value), expires };
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
module.exports = KeyvBrotli;
|
|
48
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,sEAA6C;AAG7C,MAAM,UAAU;IAEf,YAAY,OAAiB;QAC5B,IAAI,CAAC,MAAM,GAAG,IAAA,yBAAc,EAAC,OAAO,CAAC,CAAC;IACvC,CAAC;IAEK,QAAQ,CAAC,KAAU,EAAE,OAAuB;;YACjD,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAC7C,CAAC;KAAA;IAEK,UAAU,CAAI,IAAe,EAAE,OAAuB;;YAC3D,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,OAAO,CAAM,CAAC;QACzD,CAAC;KAAA;IAEK,SAAS,CAAC,EAAC,KAAK,EAAE,OAAO,EAAY;;YAC1C,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YACjD,yEAAyE;YACzE,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,EAAC,KAAK,EAAE,aAAa,EAAE,OAAO,EAAC,CAAC,CAAC;QAC/D,CAAC;KAAA;IAEK,WAAW,CAAC,IAAoB;;YACrC,kEAAkE;YAClE,IAAI,CAAC,IAAI,EAAE;gBACV,OAAO,IAAI,CAAC;aACZ;YAED,MAAM,EAAC,KAAK,EAAE,OAAO,EAAC,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAc,CAAC;YACpE,OAAO,EAAC,KAAK,EAAE,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,OAAO,EAAC,CAAC;QACvD,CAAC;KAAA;CACD;AAED,iBAAS,UAAU,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type { BrotliOptions, CompressCallback, InputType } from 'node:zlib';
|
|
3
|
+
import type { parse as JSONBparse, stringify as JSONBstringify } from 'json-buffer';
|
|
4
|
+
export type CompressResult = Promise<Parameters<CompressCallback>[1]>;
|
|
5
|
+
export type DecompressResult = Promise<ReturnType<typeof JSONBparse>>;
|
|
6
|
+
export type SerializeResult = ReturnType<typeof JSONBstringify>;
|
|
7
|
+
export type DeserializeResult = ReturnType<typeof JSONBparse>;
|
|
8
|
+
type BrotliSerialize<T> = (source: InputType) => T;
|
|
9
|
+
type BrotliDeserialize<T> = (source: CompressResult) => T;
|
|
10
|
+
export type Serialize = {
|
|
11
|
+
value: InputType;
|
|
12
|
+
expires?: number;
|
|
13
|
+
};
|
|
14
|
+
export interface Options {
|
|
15
|
+
compressOptions?: BrotliOptions;
|
|
16
|
+
decompressOptions?: BrotliOptions;
|
|
17
|
+
enable?: boolean;
|
|
18
|
+
serialize?: any;
|
|
19
|
+
deserialize?: any;
|
|
20
|
+
iltorb?: any;
|
|
21
|
+
}
|
|
22
|
+
export interface Brotli {
|
|
23
|
+
serialize: BrotliSerialize<SerializeResult>;
|
|
24
|
+
deserialize: BrotliDeserialize<DeserializeResult>;
|
|
25
|
+
compress: (data: InputType, options?: BrotliOptions) => CompressResult;
|
|
26
|
+
decompress: (data: InputType, options?: BrotliOptions) => DecompressResult;
|
|
27
|
+
}
|
|
28
|
+
export {};
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keyv/compress-brotli",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "brotli compression for keyv",
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
6
7
|
"scripts": {
|
|
7
|
-
"
|
|
8
|
+
"build": "tsc --project tsconfig.dist.json",
|
|
9
|
+
"prepare": "yarn build",
|
|
10
|
+
"test": "xo && c8 ava --serial",
|
|
8
11
|
"test:ci": "xo && ava --serial",
|
|
9
|
-
"clean": "rm -rf node_modules && rm -rf ./coverage && rm -rf ./test/testdb.sqlite"
|
|
12
|
+
"clean": "rm -rf node_modules && rm -rf ./coverage && rm -rf ./test/testdb.sqlite && rm -rf ./dist && rm -rf ./.nyc_output"
|
|
10
13
|
},
|
|
11
14
|
"xo": {
|
|
12
15
|
"rules": {
|
|
@@ -21,19 +24,10 @@
|
|
|
21
24
|
"ts"
|
|
22
25
|
]
|
|
23
26
|
}
|
|
24
|
-
]
|
|
27
|
+
],
|
|
28
|
+
"import/extensions": 0
|
|
25
29
|
}
|
|
26
30
|
},
|
|
27
|
-
"ava": {
|
|
28
|
-
"require": [
|
|
29
|
-
"requirable",
|
|
30
|
-
"ts-node/register"
|
|
31
|
-
],
|
|
32
|
-
"extensions": [
|
|
33
|
-
"js",
|
|
34
|
-
"ts"
|
|
35
|
-
]
|
|
36
|
-
},
|
|
37
31
|
"repository": {
|
|
38
32
|
"type": "git",
|
|
39
33
|
"url": "git+https://github.com/jaredwray/keyv.git"
|
|
@@ -61,25 +55,32 @@
|
|
|
61
55
|
},
|
|
62
56
|
"devDependencies": {
|
|
63
57
|
"@keyv/test-suite": "*",
|
|
64
|
-
"ava": "^5.
|
|
65
|
-
"c8": "^7.
|
|
58
|
+
"ava": "^5.2.0",
|
|
59
|
+
"c8": "^7.13.0",
|
|
66
60
|
"json-buffer": "^3.0.1",
|
|
67
61
|
"keyv": "*",
|
|
68
62
|
"requirable": "^1.0.5",
|
|
69
63
|
"ts-node": "^10.9.1",
|
|
70
|
-
"tsd": "^0.
|
|
71
|
-
"typescript": "^4.9.
|
|
64
|
+
"tsd": "^0.26.0",
|
|
65
|
+
"typescript": "^4.9.5",
|
|
72
66
|
"webpack": "^5.75.0",
|
|
73
67
|
"xo": "^0.53.1"
|
|
74
68
|
},
|
|
75
69
|
"tsd": {
|
|
76
70
|
"directory": "test"
|
|
77
71
|
},
|
|
78
|
-
"types": "./src/index.d.ts",
|
|
79
72
|
"engines": {
|
|
80
73
|
"node": ">= 12"
|
|
81
74
|
},
|
|
82
75
|
"files": [
|
|
83
|
-
"
|
|
84
|
-
]
|
|
76
|
+
"dist"
|
|
77
|
+
],
|
|
78
|
+
"ava": {
|
|
79
|
+
"extensions": [
|
|
80
|
+
"ts"
|
|
81
|
+
],
|
|
82
|
+
"require": [
|
|
83
|
+
"ts-node/register"
|
|
84
|
+
]
|
|
85
|
+
}
|
|
85
86
|
}
|
package/src/index.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type {InputType, BrotliOptions, CompressCallback} from 'node:zlib';
|
|
2
|
-
import type Brotli, {CompressResult} from 'compress-brotli';
|
|
3
|
-
|
|
4
|
-
declare class KeyvBrotli {
|
|
5
|
-
brotli: Brotli;
|
|
6
|
-
constructor(options?: KeyvBrotli.Options);
|
|
7
|
-
compress(value: InputType | number | boolean, options?: BrotliOptions): Promise<any>;
|
|
8
|
-
decompress(value: InputType | number | boolean, options?: BrotliOptions): Promise<any>;
|
|
9
|
-
serialize(value: any): Promise<any>;
|
|
10
|
-
deserialize(value: any): Promise<any>;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
declare namespace KeyvBrotli {
|
|
14
|
-
interface Options {
|
|
15
|
-
compressOptions?: BrotliOptions;
|
|
16
|
-
decompressOptions?: BrotliOptions;
|
|
17
|
-
enable?: boolean;
|
|
18
|
-
serialize?: any;
|
|
19
|
-
deserialize?: any;
|
|
20
|
-
iltorb?: any;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export = KeyvBrotli;
|
package/src/index.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
const compressBrotli = require('compress-brotli');
|
|
3
|
-
|
|
4
|
-
class KeyvBrotli {
|
|
5
|
-
constructor(options) {
|
|
6
|
-
this.brotli = compressBrotli(options);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
async compress(value, options) {
|
|
10
|
-
return this.brotli.compress(value, options);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
async decompress(data, options) {
|
|
14
|
-
return this.brotli.decompress(data, options);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
async serialize({value, expires}) {
|
|
18
|
-
return this.brotli.serialize({value: await this.compress(value), expires});
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
async deserialize(data) {
|
|
22
|
-
const {value, expires} = this.brotli.deserialize(data);
|
|
23
|
-
return {value: await this.decompress(value), expires};
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
module.exports = KeyvBrotli;
|