@keyv/compress-brotli 6.0.0-alpha.3 → 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,71 +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 brotliCompressAsync = (0, import_node_util.promisify)(import_node_zlib.brotliCompress);
30
- 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);
31
10
  var KeyvBrotli = class {
32
- _enable;
33
- _compressOptions;
34
- _decompressOptions;
35
- constructor(options) {
36
- this._enable = options?.enable ?? true;
37
- this._compressOptions = options?.compressOptions;
38
- this._decompressOptions = options?.decompressOptions;
39
- }
40
- // biome-ignore lint/suspicious/noExplicitAny: needed for this type
41
- async compress(value, options) {
42
- if (!this._enable) {
43
- return typeof value === "string" ? value : JSON.stringify(value);
44
- }
45
- const input = typeof value === "string" ? value : JSON.stringify(value);
46
- const compressed = await brotliCompressAsync(input, {
47
- ...this._compressOptions,
48
- ...options
49
- });
50
- return compressed.toString("base64");
51
- }
52
- async decompress(data, options) {
53
- if (!data) {
54
- return void 0;
55
- }
56
- if (!this._enable) {
57
- return data;
58
- }
59
- const buffer = Buffer.from(data, "base64");
60
- const decompressedBuffer = await brotliDecompressAsync(buffer, {
61
- ...this._decompressOptions,
62
- ...options
63
- });
64
- return decompressedBuffer.toString();
65
- }
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
+ }
66
23
  };
67
- var index_default = KeyvBrotli;
68
- // Annotate the CommonJS export names for ESM import in node:
69
- 0 && (module.exports = {
70
- KeyvBrotli
71
- });
24
+ //#endregion
25
+ exports.KeyvBrotli = KeyvBrotli;
26
+ exports.default = KeyvBrotli;
package/dist/index.d.cts CHANGED
@@ -1,18 +1,17 @@
1
- import { BrotliOptions } from 'node:zlib';
1
+ import { BrotliOptions } from "node:zlib";
2
+ import { KeyvCompressionAdapter } from "keyv";
2
3
 
4
+ //#region src/index.d.ts
3
5
  type Options = {
4
- compressOptions?: BrotliOptions;
5
- decompressOptions?: BrotliOptions;
6
- enable?: boolean;
6
+ compressOptions?: BrotliOptions;
7
+ decompressOptions?: BrotliOptions;
7
8
  };
8
-
9
- declare class KeyvBrotli {
10
- private readonly _enable;
11
- private readonly _compressOptions?;
12
- private readonly _decompressOptions?;
13
- constructor(options?: Options);
14
- compress(value: any, options?: BrotliOptions): Promise<string>;
15
- decompress<T>(data?: string, options?: BrotliOptions): Promise<T>;
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>;
16
15
  }
17
-
18
- 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.3",
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
  },
@@ -42,27 +42,27 @@
42
42
  "homepage": "https://github.com/jaredwray/keyv",
43
43
  "dependencies": {},
44
44
  "peerDependencies": {
45
- "keyv": "^6.0.0-alpha.3"
45
+ "keyv": "^6.0.0-beta.3"
46
46
  },
47
47
  "devDependencies": {
48
- "@biomejs/biome": "^2.3.13",
49
- "@vitest/coverage-v8": "^4.0.18",
50
- "rimraf": "^6.1.2",
51
- "vitest": "^4.0.18",
52
- "@keyv/test-suite": "^6.0.0-alpha.3"
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"
53
53
  },
54
54
  "tsd": {
55
55
  "directory": "test"
56
56
  },
57
57
  "engines": {
58
- "node": ">= 18"
58
+ "node": ">= 22.18.0"
59
59
  },
60
60
  "files": [
61
61
  "dist",
62
62
  "LICENSE"
63
63
  ],
64
64
  "scripts": {
65
- "build": "rimraf ./dist && tsup src/index.ts --format cjs,esm --dts --clean",
65
+ "build": "tsdown",
66
66
  "lint": "biome check --write --error-on-warnings",
67
67
  "lint:ci": "biome check --error-on-warnings",
68
68
  "test": "pnpm lint && vitest run --coverage",
package/dist/index.d.ts DELETED
@@ -1,18 +0,0 @@
1
- import { BrotliOptions } from 'node:zlib';
2
-
3
- type Options = {
4
- compressOptions?: BrotliOptions;
5
- decompressOptions?: BrotliOptions;
6
- enable?: boolean;
7
- };
8
-
9
- declare class KeyvBrotli {
10
- private readonly _enable;
11
- private readonly _compressOptions?;
12
- private readonly _decompressOptions?;
13
- constructor(options?: Options);
14
- compress(value: any, options?: BrotliOptions): Promise<string>;
15
- decompress<T>(data?: string, options?: BrotliOptions): Promise<T>;
16
- }
17
-
18
- export { KeyvBrotli, KeyvBrotli as default };
package/dist/index.js DELETED
@@ -1,49 +0,0 @@
1
- // src/index.ts
2
- import { promisify } from "util";
3
- import {
4
- brotliCompress,
5
- brotliDecompress
6
- } from "zlib";
7
- var brotliCompressAsync = promisify(brotliCompress);
8
- var brotliDecompressAsync = promisify(brotliDecompress);
9
- var KeyvBrotli = class {
10
- _enable;
11
- _compressOptions;
12
- _decompressOptions;
13
- constructor(options) {
14
- this._enable = options?.enable ?? true;
15
- this._compressOptions = options?.compressOptions;
16
- this._decompressOptions = options?.decompressOptions;
17
- }
18
- // biome-ignore lint/suspicious/noExplicitAny: needed for this type
19
- async compress(value, options) {
20
- if (!this._enable) {
21
- return typeof value === "string" ? value : JSON.stringify(value);
22
- }
23
- const input = typeof value === "string" ? value : JSON.stringify(value);
24
- const compressed = await brotliCompressAsync(input, {
25
- ...this._compressOptions,
26
- ...options
27
- });
28
- return compressed.toString("base64");
29
- }
30
- async decompress(data, options) {
31
- if (!data) {
32
- return void 0;
33
- }
34
- if (!this._enable) {
35
- return data;
36
- }
37
- const buffer = Buffer.from(data, "base64");
38
- const decompressedBuffer = await brotliDecompressAsync(buffer, {
39
- ...this._decompressOptions,
40
- ...options
41
- });
42
- return decompressedBuffer.toString();
43
- }
44
- };
45
- var index_default = KeyvBrotli;
46
- export {
47
- KeyvBrotli,
48
- index_default as default
49
- };