@keyv/compress-lz4 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-lz4 [<img width="100" align="right" src="https://jaredwray.com/images/keyv-symbol.svg" alt="keyv">](https://github.com/jaredwra/keyv)
1
+ # @keyv/compress-lz4 [<img width="100" align="right" src="https://jaredwray.com/images/keyv-symbol.svg" alt="keyv">](https://github.com/jaredwray/keyv)
2
2
 
3
3
  > lz4 compression for Keyv
4
4
 
package/dist/index.cjs CHANGED
@@ -1,61 +1,25 @@
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
- KeyvLz4: () => KeyvLz4,
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_buffer = require("buffer");
28
- var import_serialize = require("@keyv/serialize");
29
- var import_lz4_napi = require("lz4-napi");
5
+ let node_buffer = require("node:buffer");
6
+ let lz4_napi = require("lz4-napi");
7
+ //#region src/index.ts
30
8
  var KeyvLz4 = class {
31
- constructor(dictionary) {
32
- this.dictionary = dictionary;
33
- }
34
- async compress(data) {
35
- return (0, import_lz4_napi.compress)(import_node_buffer.Buffer.from(data), this.getDictionary());
36
- }
37
- async decompress(data) {
38
- const value = await (0, import_lz4_napi.uncompress)(import_node_buffer.Buffer.from(data), this.getDictionary());
39
- return value.toString("utf8");
40
- }
41
- async serialize({ value, expires }) {
42
- const compressedUint8Array = await this.compress(value);
43
- return (0, import_serialize.defaultSerialize)({ value: compressedUint8Array, expires });
44
- }
45
- async deserialize(data) {
46
- const { value, expires } = (0, import_serialize.defaultDeserialize)(data);
47
- const uncompressedUint8Array = await this.decompress(value);
48
- return { value: uncompressedUint8Array, expires };
49
- }
50
- getDictionary() {
51
- if (this.dictionary) {
52
- return import_node_buffer.Buffer.from(this.dictionary);
53
- }
54
- return void 0;
55
- }
9
+ dictionary;
10
+ constructor(dictionary) {
11
+ this.dictionary = dictionary;
12
+ }
13
+ async compress(data) {
14
+ return (await (0, lz4_napi.compress)(node_buffer.Buffer.from(data), this.getDictionary())).toString("base64");
15
+ }
16
+ async decompress(data) {
17
+ return (await (0, lz4_napi.uncompress)(node_buffer.Buffer.from(data, "base64"), this.getDictionary())).toString("utf8");
18
+ }
19
+ getDictionary() {
20
+ if (this.dictionary) return node_buffer.Buffer.from(this.dictionary);
21
+ }
56
22
  };
57
- var index_default = KeyvLz4;
58
- // Annotate the CommonJS export names for ESM import in node:
59
- 0 && (module.exports = {
60
- KeyvLz4
61
- });
23
+ //#endregion
24
+ exports.KeyvLz4 = KeyvLz4;
25
+ exports.default = KeyvLz4;
package/dist/index.d.cts CHANGED
@@ -1,16 +1,12 @@
1
- type Serialize = {
2
- value: string;
3
- expires?: number;
4
- };
1
+ import { KeyvCompressionAdapter } from "keyv";
5
2
 
6
- declare class KeyvLz4 {
7
- private readonly dictionary?;
8
- constructor(dictionary?: string | undefined);
9
- compress(data: string): Promise<Uint8Array>;
10
- decompress(data: Uint8Array): Promise<string>;
11
- serialize({ value, expires }: Serialize): Promise<string>;
12
- deserialize(data: string): Promise<Serialize>;
13
- private getDictionary;
3
+ //#region src/index.d.ts
4
+ declare class KeyvLz4 implements KeyvCompressionAdapter {
5
+ private readonly dictionary?;
6
+ constructor(dictionary?: string | undefined);
7
+ compress(data: string): Promise<string>;
8
+ decompress(data: string): Promise<string>;
9
+ private getDictionary;
14
10
  }
15
-
16
- export { KeyvLz4, KeyvLz4 as default };
11
+ //#endregion
12
+ export { KeyvLz4, KeyvLz4 as default };
@@ -0,0 +1,12 @@
1
+ import { KeyvCompressionAdapter } from "keyv";
2
+
3
+ //#region src/index.d.ts
4
+ declare class KeyvLz4 implements KeyvCompressionAdapter {
5
+ private readonly dictionary?;
6
+ constructor(dictionary?: string | undefined);
7
+ compress(data: string): Promise<string>;
8
+ decompress(data: string): Promise<string>;
9
+ private getDictionary;
10
+ }
11
+ //#endregion
12
+ export { KeyvLz4, KeyvLz4 as default };
package/dist/index.mjs ADDED
@@ -0,0 +1,20 @@
1
+ import { Buffer } from "node:buffer";
2
+ import { compress, uncompress } from "lz4-napi";
3
+ //#region src/index.ts
4
+ var KeyvLz4 = class {
5
+ dictionary;
6
+ constructor(dictionary) {
7
+ this.dictionary = dictionary;
8
+ }
9
+ async compress(data) {
10
+ return (await compress(Buffer.from(data), this.getDictionary())).toString("base64");
11
+ }
12
+ async decompress(data) {
13
+ return (await uncompress(Buffer.from(data, "base64"), this.getDictionary())).toString("utf8");
14
+ }
15
+ getDictionary() {
16
+ if (this.dictionary) return Buffer.from(this.dictionary);
17
+ }
18
+ };
19
+ //#endregion
20
+ export { KeyvLz4, KeyvLz4 as default };
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@keyv/compress-lz4",
3
- "version": "6.0.0-alpha.2",
3
+ "version": "6.0.0-beta.3",
4
4
  "description": "lz4 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
  },
@@ -43,31 +43,30 @@
43
43
  },
44
44
  "homepage": "https://github.com/jaredwray/keyv",
45
45
  "dependencies": {
46
- "lz4-napi": "^2.9.0",
47
- "@keyv/serialize": "^6.0.0-alpha.2"
46
+ "lz4-napi": "^2.9.0"
48
47
  },
49
48
  "peerDependencies": {
50
- "keyv": "^6.0.0-alpha.2"
49
+ "keyv": "^6.0.0-beta.3"
51
50
  },
52
51
  "devDependencies": {
53
- "@biomejs/biome": "^2.3.8",
54
- "@vitest/coverage-v8": "^4.0.14",
55
- "rimraf": "^6.1.2",
56
- "vitest": "^4.0.14",
57
- "@keyv/test-suite": "^6.0.0-alpha.2"
52
+ "@biomejs/biome": "^2.4.16",
53
+ "@vitest/coverage-v8": "^4.1.8",
54
+ "rimraf": "^6.1.3",
55
+ "vitest": "^4.1.8",
56
+ "@keyv/test-suite": "^6.0.0-beta.3"
58
57
  },
59
58
  "tsd": {
60
59
  "directory": "test"
61
60
  },
62
61
  "engines": {
63
- "node": ">= 18"
62
+ "node": ">= 22.18.0"
64
63
  },
65
64
  "files": [
66
65
  "dist",
67
66
  "LICENSE"
68
67
  ],
69
68
  "scripts": {
70
- "build": "rimraf ./dist && tsup src/index.ts --format cjs,esm --dts --clean",
69
+ "build": "tsdown",
71
70
  "lint": "biome check --write --error-on-warnings",
72
71
  "lint:ci": "biome check --error-on-warnings",
73
72
  "test": "pnpm lint && vitest run --coverage",
package/dist/index.d.ts DELETED
@@ -1,16 +0,0 @@
1
- type Serialize = {
2
- value: string;
3
- expires?: number;
4
- };
5
-
6
- declare class KeyvLz4 {
7
- private readonly dictionary?;
8
- constructor(dictionary?: string | undefined);
9
- compress(data: string): Promise<Uint8Array>;
10
- decompress(data: Uint8Array): Promise<string>;
11
- serialize({ value, expires }: Serialize): Promise<string>;
12
- deserialize(data: string): Promise<Serialize>;
13
- private getDictionary;
14
- }
15
-
16
- export { KeyvLz4, KeyvLz4 as default };
package/dist/index.js DELETED
@@ -1,36 +0,0 @@
1
- // src/index.ts
2
- import { Buffer } from "buffer";
3
- import { defaultDeserialize, defaultSerialize } from "@keyv/serialize";
4
- import { compress, uncompress } from "lz4-napi";
5
- var KeyvLz4 = class {
6
- constructor(dictionary) {
7
- this.dictionary = dictionary;
8
- }
9
- async compress(data) {
10
- return compress(Buffer.from(data), this.getDictionary());
11
- }
12
- async decompress(data) {
13
- const value = await uncompress(Buffer.from(data), this.getDictionary());
14
- return value.toString("utf8");
15
- }
16
- async serialize({ value, expires }) {
17
- const compressedUint8Array = await this.compress(value);
18
- return defaultSerialize({ value: compressedUint8Array, expires });
19
- }
20
- async deserialize(data) {
21
- const { value, expires } = defaultDeserialize(data);
22
- const uncompressedUint8Array = await this.decompress(value);
23
- return { value: uncompressedUint8Array, expires };
24
- }
25
- getDictionary() {
26
- if (this.dictionary) {
27
- return Buffer.from(this.dictionary);
28
- }
29
- return void 0;
30
- }
31
- };
32
- var index_default = KeyvLz4;
33
- export {
34
- KeyvLz4,
35
- index_default as default
36
- };