@keyv/compress-brotli 6.0.0-alpha.2 → 6.0.0-beta.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/LICENSE CHANGED
@@ -1,7 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2017-2021 Luke Childs
4
- Copyright (c) 2021-2022 Jared Wray
3
+ Copyright (c) 2021-2026 Jared Wray
5
4
 
6
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
7
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # @keyv/compress-brotli [<img width="100" align="right" src="https://jaredwray.com/images/keyv-symbol.svg" alt="keyv">](https://github.com/jaredwra/keyv)
1
+ # @keyv/compress-brotli [<img width="100" align="right" src="https://jaredwray.com/images/keyv-symbol.svg" alt="keyv">](https://github.com/jaredwray/keyv)
2
2
 
3
3
  > Brotli compression for Keyv
4
4
 
package/dist/index.cjs CHANGED
@@ -1,86 +1,26 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- KeyvBrotli: () => KeyvBrotli,
24
- default: () => index_default
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
25
4
  });
26
- module.exports = __toCommonJS(index_exports);
27
- var import_node_util = require("util");
28
- var import_node_zlib = require("zlib");
29
- var import_serialize = require("@keyv/serialize");
30
- var brotliCompressAsync = (0, import_node_util.promisify)(import_node_zlib.brotliCompress);
31
- var brotliDecompressAsync = (0, import_node_util.promisify)(import_node_zlib.brotliDecompress);
5
+ let node_util = require("node:util");
6
+ let node_zlib = require("node:zlib");
7
+ //#region src/index.ts
8
+ const brotliCompressAsync = (0, node_util.promisify)(node_zlib.brotliCompress);
9
+ const brotliDecompressAsync = (0, node_util.promisify)(node_zlib.brotliDecompress);
32
10
  var KeyvBrotli = class {
33
- _enable;
34
- _compressOptions;
35
- _decompressOptions;
36
- // biome-ignore lint/suspicious/noExplicitAny: needed for custom serializers like v8
37
- _serialize;
38
- // biome-ignore lint/suspicious/noExplicitAny: needed for custom serializers like v8
39
- _deserialize;
40
- constructor(options) {
41
- this._enable = options?.enable ?? true;
42
- this._compressOptions = options?.compressOptions;
43
- this._decompressOptions = options?.decompressOptions;
44
- this._serialize = options?.serialize ?? import_serialize.defaultSerialize;
45
- this._deserialize = options?.deserialize ?? import_serialize.defaultDeserialize;
46
- }
47
- // biome-ignore lint/suspicious/noExplicitAny: needed for this type
48
- async compress(value, options) {
49
- if (!this._enable) {
50
- return value;
51
- }
52
- const serializedData = this._serialize(value);
53
- return brotliCompressAsync(serializedData, {
54
- ...this._compressOptions,
55
- ...options
56
- });
57
- }
58
- async decompress(data, options) {
59
- if (!data) {
60
- return void 0;
61
- }
62
- if (!this._enable) {
63
- return data;
64
- }
65
- const decompressedBuffer = await brotliDecompressAsync(data, {
66
- ...this._decompressOptions,
67
- ...options
68
- });
69
- return this._deserialize(decompressedBuffer);
70
- }
71
- async serialize({ value, expires }) {
72
- return (0, import_serialize.defaultSerialize)({ value: await this.compress(value), expires });
73
- }
74
- async deserialize(data) {
75
- if (data) {
76
- const { value, expires } = (0, import_serialize.defaultDeserialize)(data);
77
- return { value: await this.decompress(value), expires };
78
- }
79
- return { value: void 0, expires: void 0 };
80
- }
11
+ _compressOptions;
12
+ _decompressOptions;
13
+ constructor(options) {
14
+ this._compressOptions = options?.compressOptions;
15
+ this._decompressOptions = options?.decompressOptions;
16
+ }
17
+ async compress(value) {
18
+ return (await brotliCompressAsync(value, { ...this._compressOptions })).toString("base64");
19
+ }
20
+ async decompress(value) {
21
+ return (await brotliDecompressAsync(Buffer.from(value, "base64"), { ...this._decompressOptions })).toString();
22
+ }
81
23
  };
82
- var index_default = KeyvBrotli;
83
- // Annotate the CommonJS export names for ESM import in node:
84
- 0 && (module.exports = {
85
- KeyvBrotli
86
- });
24
+ //#endregion
25
+ exports.KeyvBrotli = KeyvBrotli;
26
+ exports.default = KeyvBrotli;
package/dist/index.d.cts CHANGED
@@ -1,30 +1,17 @@
1
- import { BrotliOptions, InputType } from 'node:zlib';
1
+ import { BrotliOptions } from "node:zlib";
2
+ import { KeyvCompressionAdapter } from "keyv";
2
3
 
3
- type CompressResult = Promise<any>;
4
- type SerializeResult = string;
5
- type Serialize = {
6
- value?: InputType;
7
- expires?: number;
8
- };
4
+ //#region src/index.d.ts
9
5
  type Options = {
10
- compressOptions?: BrotliOptions;
11
- decompressOptions?: BrotliOptions;
12
- enable?: boolean;
13
- serialize?: (value: any) => any;
14
- deserialize?: (data: any) => any;
6
+ compressOptions?: BrotliOptions;
7
+ decompressOptions?: BrotliOptions;
15
8
  };
16
-
17
- declare class KeyvBrotli {
18
- private readonly _enable;
19
- private readonly _compressOptions?;
20
- private readonly _decompressOptions?;
21
- private readonly _serialize;
22
- private readonly _deserialize;
23
- constructor(options?: Options);
24
- compress(value: any, options?: BrotliOptions): CompressResult;
25
- decompress<T>(data?: InputType, options?: BrotliOptions): Promise<T>;
26
- serialize({ value, expires }: Serialize): Promise<SerializeResult>;
27
- deserialize(data?: CompressResult): Promise<Serialize>;
9
+ declare class KeyvBrotli implements KeyvCompressionAdapter {
10
+ private readonly _compressOptions?;
11
+ private readonly _decompressOptions?;
12
+ constructor(options?: Options);
13
+ compress(value: string): Promise<string>;
14
+ decompress(value: string): Promise<string>;
28
15
  }
29
-
30
- export { KeyvBrotli, KeyvBrotli as default };
16
+ //#endregion
17
+ export { KeyvBrotli, KeyvBrotli as default, Options };
@@ -0,0 +1,17 @@
1
+ import { BrotliOptions } from "node:zlib";
2
+ import { KeyvCompressionAdapter } from "keyv";
3
+
4
+ //#region src/index.d.ts
5
+ type Options = {
6
+ compressOptions?: BrotliOptions;
7
+ decompressOptions?: BrotliOptions;
8
+ };
9
+ declare class KeyvBrotli implements KeyvCompressionAdapter {
10
+ private readonly _compressOptions?;
11
+ private readonly _decompressOptions?;
12
+ constructor(options?: Options);
13
+ compress(value: string): Promise<string>;
14
+ decompress(value: string): Promise<string>;
15
+ }
16
+ //#endregion
17
+ export { KeyvBrotli, KeyvBrotli as default, Options };
package/dist/index.mjs ADDED
@@ -0,0 +1,21 @@
1
+ import { promisify } from "node:util";
2
+ import { brotliCompress, brotliDecompress } from "node:zlib";
3
+ //#region src/index.ts
4
+ const brotliCompressAsync = promisify(brotliCompress);
5
+ const brotliDecompressAsync = promisify(brotliDecompress);
6
+ var KeyvBrotli = class {
7
+ _compressOptions;
8
+ _decompressOptions;
9
+ constructor(options) {
10
+ this._compressOptions = options?.compressOptions;
11
+ this._decompressOptions = options?.decompressOptions;
12
+ }
13
+ async compress(value) {
14
+ return (await brotliCompressAsync(value, { ...this._compressOptions })).toString("base64");
15
+ }
16
+ async decompress(value) {
17
+ return (await brotliDecompressAsync(Buffer.from(value, "base64"), { ...this._decompressOptions })).toString();
18
+ }
19
+ };
20
+ //#endregion
21
+ export { KeyvBrotli, KeyvBrotli as default };
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@keyv/compress-brotli",
3
- "version": "6.0.0-alpha.2",
3
+ "version": "6.0.0-beta.3",
4
4
  "description": "brotli compression for keyv",
5
5
  "type": "module",
6
- "main": "./dist/index.js",
7
- "module": "./dist/index.js",
8
- "types": "./dist/index.d.ts",
6
+ "main": "./dist/index.mjs",
7
+ "module": "./dist/index.mjs",
8
+ "types": "./dist/index.d.mts",
9
9
  "exports": {
10
10
  ".": {
11
11
  "require": {
@@ -13,8 +13,8 @@
13
13
  "default": "./dist/index.cjs"
14
14
  },
15
15
  "import": {
16
- "types": "./dist/index.d.ts",
17
- "default": "./dist/index.js"
16
+ "types": "./dist/index.d.mts",
17
+ "default": "./dist/index.mjs"
18
18
  }
19
19
  }
20
20
  },
@@ -40,31 +40,29 @@
40
40
  "url": "https://github.com/jaredwray/keyv/issues"
41
41
  },
42
42
  "homepage": "https://github.com/jaredwray/keyv",
43
- "dependencies": {
44
- "@keyv/serialize": "^6.0.0-alpha.2"
45
- },
43
+ "dependencies": {},
46
44
  "peerDependencies": {
47
- "keyv": "^6.0.0-alpha.2"
45
+ "keyv": "^6.0.0-beta.3"
48
46
  },
49
47
  "devDependencies": {
50
- "@biomejs/biome": "^2.3.13",
51
- "@vitest/coverage-v8": "^4.0.18",
52
- "rimraf": "^6.1.2",
53
- "vitest": "^4.0.18",
54
- "@keyv/test-suite": "^6.0.0-alpha.2"
48
+ "@biomejs/biome": "^2.4.16",
49
+ "@vitest/coverage-v8": "^4.1.8",
50
+ "rimraf": "^6.1.3",
51
+ "vitest": "^4.1.8",
52
+ "@keyv/test-suite": "^6.0.0-beta.3"
55
53
  },
56
54
  "tsd": {
57
55
  "directory": "test"
58
56
  },
59
57
  "engines": {
60
- "node": ">= 18"
58
+ "node": ">= 22.18.0"
61
59
  },
62
60
  "files": [
63
61
  "dist",
64
62
  "LICENSE"
65
63
  ],
66
64
  "scripts": {
67
- "build": "rimraf ./dist && tsup src/index.ts --format cjs,esm --dts --clean",
65
+ "build": "tsdown",
68
66
  "lint": "biome check --write --error-on-warnings",
69
67
  "lint:ci": "biome check --error-on-warnings",
70
68
  "test": "pnpm lint && vitest run --coverage",
package/dist/index.d.ts DELETED
@@ -1,30 +0,0 @@
1
- import { BrotliOptions, InputType } from 'node:zlib';
2
-
3
- type CompressResult = Promise<any>;
4
- type SerializeResult = string;
5
- type Serialize = {
6
- value?: InputType;
7
- expires?: number;
8
- };
9
- type Options = {
10
- compressOptions?: BrotliOptions;
11
- decompressOptions?: BrotliOptions;
12
- enable?: boolean;
13
- serialize?: (value: any) => any;
14
- deserialize?: (data: any) => any;
15
- };
16
-
17
- declare class KeyvBrotli {
18
- private readonly _enable;
19
- private readonly _compressOptions?;
20
- private readonly _decompressOptions?;
21
- private readonly _serialize;
22
- private readonly _deserialize;
23
- constructor(options?: Options);
24
- compress(value: any, options?: BrotliOptions): CompressResult;
25
- decompress<T>(data?: InputType, options?: BrotliOptions): Promise<T>;
26
- serialize({ value, expires }: Serialize): Promise<SerializeResult>;
27
- deserialize(data?: CompressResult): Promise<Serialize>;
28
- }
29
-
30
- export { KeyvBrotli, KeyvBrotli as default };
package/dist/index.js DELETED
@@ -1,64 +0,0 @@
1
- // src/index.ts
2
- import { promisify } from "util";
3
- import {
4
- brotliCompress,
5
- brotliDecompress
6
- } from "zlib";
7
- import { defaultDeserialize, defaultSerialize } from "@keyv/serialize";
8
- var brotliCompressAsync = promisify(brotliCompress);
9
- var brotliDecompressAsync = promisify(brotliDecompress);
10
- var KeyvBrotli = class {
11
- _enable;
12
- _compressOptions;
13
- _decompressOptions;
14
- // biome-ignore lint/suspicious/noExplicitAny: needed for custom serializers like v8
15
- _serialize;
16
- // biome-ignore lint/suspicious/noExplicitAny: needed for custom serializers like v8
17
- _deserialize;
18
- constructor(options) {
19
- this._enable = options?.enable ?? true;
20
- this._compressOptions = options?.compressOptions;
21
- this._decompressOptions = options?.decompressOptions;
22
- this._serialize = options?.serialize ?? defaultSerialize;
23
- this._deserialize = options?.deserialize ?? defaultDeserialize;
24
- }
25
- // biome-ignore lint/suspicious/noExplicitAny: needed for this type
26
- async compress(value, options) {
27
- if (!this._enable) {
28
- return value;
29
- }
30
- const serializedData = this._serialize(value);
31
- return brotliCompressAsync(serializedData, {
32
- ...this._compressOptions,
33
- ...options
34
- });
35
- }
36
- async decompress(data, options) {
37
- if (!data) {
38
- return void 0;
39
- }
40
- if (!this._enable) {
41
- return data;
42
- }
43
- const decompressedBuffer = await brotliDecompressAsync(data, {
44
- ...this._decompressOptions,
45
- ...options
46
- });
47
- return this._deserialize(decompressedBuffer);
48
- }
49
- async serialize({ value, expires }) {
50
- return defaultSerialize({ value: await this.compress(value), expires });
51
- }
52
- async deserialize(data) {
53
- if (data) {
54
- const { value, expires } = defaultDeserialize(data);
55
- return { value: await this.decompress(value), expires };
56
- }
57
- return { value: void 0, expires: void 0 };
58
- }
59
- };
60
- var index_default = KeyvBrotli;
61
- export {
62
- KeyvBrotli,
63
- index_default as default
64
- };