@keyv/compress-brotli 2.0.0 → 2.0.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/dist/index.cjs ADDED
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ KeyvBrotli: () => KeyvBrotli,
34
+ default: () => src_default
35
+ });
36
+ module.exports = __toCommonJS(src_exports);
37
+ var import_compress_brotli = __toESM(require("compress-brotli"), 1);
38
+ var import_serialize = require("@keyv/serialize");
39
+ var KeyvBrotli = class {
40
+ brotli;
41
+ constructor(options) {
42
+ this.brotli = (0, import_compress_brotli.default)(options);
43
+ }
44
+ async compress(value, options) {
45
+ return this.brotli.compress(value, options);
46
+ }
47
+ async decompress(data, options) {
48
+ return await this.brotli.decompress(data, options);
49
+ }
50
+ async serialize({ value, expires }) {
51
+ return (0, import_serialize.defaultSerialize)({ value: await this.compress(value), expires });
52
+ }
53
+ async deserialize(data) {
54
+ const { value, expires } = (0, import_serialize.defaultDeserialize)(data);
55
+ return { value: await this.decompress(value), expires };
56
+ }
57
+ };
58
+ var src_default = KeyvBrotli;
59
+ // Annotate the CommonJS export names for ESM import in node:
60
+ 0 && (module.exports = {
61
+ KeyvBrotli
62
+ });
@@ -0,0 +1,27 @@
1
+ import { CompressCallback, InputType, BrotliOptions } from 'node:zlib';
2
+
3
+ type CompressResult = Promise<Parameters<CompressCallback>[1]>;
4
+ type SerializeResult = string;
5
+ type Serialize = {
6
+ value: InputType;
7
+ expires?: number;
8
+ };
9
+ interface Options {
10
+ compressOptions?: BrotliOptions;
11
+ decompressOptions?: BrotliOptions;
12
+ enable?: boolean;
13
+ serialize?: any;
14
+ deserialize?: any;
15
+ iltorb?: any;
16
+ }
17
+
18
+ declare class KeyvBrotli {
19
+ private readonly brotli;
20
+ constructor(options?: Options);
21
+ compress(value: any, options?: BrotliOptions): CompressResult;
22
+ decompress<T>(data: InputType, options?: BrotliOptions): Promise<T>;
23
+ serialize({ value, expires }: Serialize): Promise<SerializeResult>;
24
+ deserialize(data: CompressResult): Promise<Serialize>;
25
+ }
26
+
27
+ export { KeyvBrotli, KeyvBrotli as default };
@@ -0,0 +1,27 @@
1
+ import { CompressCallback, InputType, BrotliOptions } from 'node:zlib';
2
+
3
+ type CompressResult = Promise<Parameters<CompressCallback>[1]>;
4
+ type SerializeResult = string;
5
+ type Serialize = {
6
+ value: InputType;
7
+ expires?: number;
8
+ };
9
+ interface Options {
10
+ compressOptions?: BrotliOptions;
11
+ decompressOptions?: BrotliOptions;
12
+ enable?: boolean;
13
+ serialize?: any;
14
+ deserialize?: any;
15
+ iltorb?: any;
16
+ }
17
+
18
+ declare class KeyvBrotli {
19
+ private readonly brotli;
20
+ constructor(options?: Options);
21
+ compress(value: any, options?: BrotliOptions): CompressResult;
22
+ decompress<T>(data: InputType, options?: BrotliOptions): Promise<T>;
23
+ serialize({ value, expires }: Serialize): Promise<SerializeResult>;
24
+ deserialize(data: CompressResult): Promise<Serialize>;
25
+ }
26
+
27
+ export { KeyvBrotli, KeyvBrotli as default };
package/dist/index.js ADDED
@@ -0,0 +1,27 @@
1
+ // src/index.ts
2
+ import compressBrotli from "compress-brotli";
3
+ import { defaultDeserialize, defaultSerialize } from "@keyv/serialize";
4
+ var KeyvBrotli = class {
5
+ brotli;
6
+ constructor(options) {
7
+ this.brotli = compressBrotli(options);
8
+ }
9
+ async compress(value, options) {
10
+ return this.brotli.compress(value, options);
11
+ }
12
+ async decompress(data, options) {
13
+ return await this.brotli.decompress(data, options);
14
+ }
15
+ async serialize({ value, expires }) {
16
+ return defaultSerialize({ value: await this.compress(value), expires });
17
+ }
18
+ async deserialize(data) {
19
+ const { value, expires } = defaultDeserialize(data);
20
+ return { value: await this.decompress(value), expires };
21
+ }
22
+ };
23
+ var src_default = KeyvBrotli;
24
+ export {
25
+ KeyvBrotli,
26
+ src_default as default
27
+ };
package/package.json CHANGED
@@ -1,18 +1,19 @@
1
1
  {
2
2
  "name": "@keyv/compress-brotli",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "brotli compression for keyv",
5
- "main": "dist/cjs/index.js",
6
- "module": "dist/esm/index.js",
7
- "types": "dist/esm/index.d.ts",
5
+ "type": "module",
6
+ "main": "dist/index.cjs",
7
+ "module": "dist/index.js",
8
+ "types": "dist/index.d.ts",
8
9
  "exports": {
9
10
  ".": {
10
- "require": "./dist/cjs/index.js",
11
- "import": "./dist/esm/index.js"
11
+ "require": "./dist/index.cjs",
12
+ "import": "./dist/index.js"
12
13
  }
13
14
  },
14
15
  "scripts": {
15
- "build": "rm -rf dist && tsc --project tsconfig.cjs.json && tsc --project tsconfig.esm.json",
16
+ "build": "rm -rf dist && tsup src/index.ts --format cjs,esm --dts --clean",
16
17
  "prepare": "yarn build",
17
18
  "test": "xo --fix && vitest run --coverage",
18
19
  "test:ci": "xo && vitest --run --sequence.setupFiles=list",
@@ -20,6 +21,7 @@
20
21
  },
21
22
  "xo": {
22
23
  "rules": {
24
+ "import/no-named-as-default": "off",
23
25
  "unicorn/prefer-module": "off",
24
26
  "@typescript-eslint/no-unsafe-call": "off",
25
27
  "@typescript-eslint/consistent-type-definitions": "off",
@@ -1,11 +0,0 @@
1
- import type { BrotliOptions, InputType } from 'node:zlib';
2
- import type { CompressResult, Options, SerializeResult, Serialize } from './types.js';
3
- declare class KeyvBrotli {
4
- private readonly brotli;
5
- constructor(options?: Options);
6
- compress(value: any, options?: BrotliOptions): CompressResult;
7
- decompress<T>(data: InputType, options?: BrotliOptions): Promise<T>;
8
- serialize({ value, expires }: Serialize): Promise<SerializeResult>;
9
- deserialize(data: CompressResult): Promise<Serialize>;
10
- }
11
- export default KeyvBrotli;
package/dist/cjs/index.js DELETED
@@ -1,28 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const compress_brotli_1 = __importDefault(require("compress-brotli"));
7
- const serialize_1 = require("@keyv/serialize");
8
- class KeyvBrotli {
9
- brotli;
10
- constructor(options) {
11
- this.brotli = (0, compress_brotli_1.default)(options);
12
- }
13
- async compress(value, options) {
14
- return this.brotli.compress(value, options);
15
- }
16
- async decompress(data, options) {
17
- return await this.brotli.decompress(data, options);
18
- }
19
- async serialize({ value, expires }) {
20
- return (0, serialize_1.defaultSerialize)({ value: await this.compress(value), expires });
21
- }
22
- async deserialize(data) {
23
- const { value, expires } = (0, serialize_1.defaultDeserialize)(data);
24
- return { value: await this.decompress(value), expires };
25
- }
26
- }
27
- exports.default = KeyvBrotli;
28
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;AACA,sEAA6C;AAC7C,+CAAqE;AAKrE,MAAM,UAAU;IACE,MAAM,CAAS;IAChC,YAAY,OAAiB;QAC5B,IAAI,CAAC,MAAM,GAAG,IAAA,yBAAc,EAAC,OAAO,CAAC,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,KAAU,EAAE,OAAuB;QACjD,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC7C,CAAC;IAED,KAAK,CAAC,UAAU,CAAI,IAAe,EAAE,OAAuB;QAC3D,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,OAAO,CAAM,CAAC;IACzD,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,EAAC,KAAK,EAAE,OAAO,EAAY;QAC1C,OAAO,IAAA,4BAAgB,EAAC,EAAC,KAAK,EAAE,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,EAAC,CAAC,CAAC;IACvE,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,IAAoB;QACrC,MAAM,EAAC,KAAK,EAAE,OAAO,EAAC,GAAc,IAAA,8BAAkB,EAAC,IAAI,CAAC,CAAC;QAC7D,OAAO,EAAC,KAAK,EAAE,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,OAAO,EAAC,CAAC;IACvD,CAAC;CACD;AAED,kBAAe,UAAU,CAAC"}
@@ -1,26 +0,0 @@
1
- import type { BrotliOptions, CompressCallback, InputType } from 'node:zlib';
2
- export type CompressResult = Promise<Parameters<CompressCallback>[1]>;
3
- export type DecompressResult = Promise<any>;
4
- export type SerializeResult = string;
5
- export type DeserializeResult = any;
6
- type BrotliSerialize<T> = (source: InputType) => T;
7
- type BrotliDeserialize<T> = (source: CompressResult) => T;
8
- export type Serialize = {
9
- value: InputType;
10
- expires?: number;
11
- };
12
- export interface Options {
13
- compressOptions?: BrotliOptions;
14
- decompressOptions?: BrotliOptions;
15
- enable?: boolean;
16
- serialize?: any;
17
- deserialize?: any;
18
- iltorb?: any;
19
- }
20
- export interface Brotli {
21
- serialize: BrotliSerialize<SerializeResult>;
22
- deserialize: BrotliDeserialize<DeserializeResult>;
23
- compress: (data: InputType, options?: BrotliOptions) => CompressResult;
24
- decompress: (data: InputType, options?: BrotliOptions) => DecompressResult;
25
- }
26
- export {};
package/dist/cjs/types.js DELETED
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
@@ -1,11 +0,0 @@
1
- import type { BrotliOptions, InputType } from 'node:zlib';
2
- import type { CompressResult, Options, SerializeResult, Serialize } from './types.js';
3
- declare class KeyvBrotli {
4
- private readonly brotli;
5
- constructor(options?: Options);
6
- compress(value: any, options?: BrotliOptions): CompressResult;
7
- decompress<T>(data: InputType, options?: BrotliOptions): Promise<T>;
8
- serialize({ value, expires }: Serialize): Promise<SerializeResult>;
9
- deserialize(data: CompressResult): Promise<Serialize>;
10
- }
11
- export default KeyvBrotli;
package/dist/esm/index.js DELETED
@@ -1,23 +0,0 @@
1
- import compressBrotli from 'compress-brotli';
2
- import { defaultDeserialize, defaultSerialize } from '@keyv/serialize';
3
- class KeyvBrotli {
4
- brotli;
5
- constructor(options) {
6
- this.brotli = compressBrotli(options);
7
- }
8
- async compress(value, options) {
9
- return this.brotli.compress(value, options);
10
- }
11
- async decompress(data, options) {
12
- return await this.brotli.decompress(data, options);
13
- }
14
- async serialize({ value, expires }) {
15
- return defaultSerialize({ value: await this.compress(value), expires });
16
- }
17
- async deserialize(data) {
18
- const { value, expires } = defaultDeserialize(data);
19
- return { value: await this.decompress(value), expires };
20
- }
21
- }
22
- export default KeyvBrotli;
23
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,cAAc,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAC,kBAAkB,EAAE,gBAAgB,EAAC,MAAM,iBAAiB,CAAC;AAKrE,MAAM,UAAU;IACE,MAAM,CAAS;IAChC,YAAY,OAAiB;QAC5B,IAAI,CAAC,MAAM,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,KAAU,EAAE,OAAuB;QACjD,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IAC7C,CAAC;IAED,KAAK,CAAC,UAAU,CAAI,IAAe,EAAE,OAAuB;QAC3D,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,OAAO,CAAM,CAAC;IACzD,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,EAAC,KAAK,EAAE,OAAO,EAAY;QAC1C,OAAO,gBAAgB,CAAC,EAAC,KAAK,EAAE,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,EAAC,CAAC,CAAC;IACvE,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,IAAoB;QACrC,MAAM,EAAC,KAAK,EAAE,OAAO,EAAC,GAAc,kBAAkB,CAAC,IAAI,CAAC,CAAC;QAC7D,OAAO,EAAC,KAAK,EAAE,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,OAAO,EAAC,CAAC;IACvD,CAAC;CACD;AAED,eAAe,UAAU,CAAC"}
@@ -1,26 +0,0 @@
1
- import type { BrotliOptions, CompressCallback, InputType } from 'node:zlib';
2
- export type CompressResult = Promise<Parameters<CompressCallback>[1]>;
3
- export type DecompressResult = Promise<any>;
4
- export type SerializeResult = string;
5
- export type DeserializeResult = any;
6
- type BrotliSerialize<T> = (source: InputType) => T;
7
- type BrotliDeserialize<T> = (source: CompressResult) => T;
8
- export type Serialize = {
9
- value: InputType;
10
- expires?: number;
11
- };
12
- export interface Options {
13
- compressOptions?: BrotliOptions;
14
- decompressOptions?: BrotliOptions;
15
- enable?: boolean;
16
- serialize?: any;
17
- deserialize?: any;
18
- iltorb?: any;
19
- }
20
- export interface Brotli {
21
- serialize: BrotliSerialize<SerializeResult>;
22
- deserialize: BrotliDeserialize<DeserializeResult>;
23
- compress: (data: InputType, options?: BrotliOptions) => CompressResult;
24
- decompress: (data: InputType, options?: BrotliOptions) => DecompressResult;
25
- }
26
- export {};
package/dist/esm/types.js DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}