@keyv/compress-lz4 6.0.0-alpha.1 → 6.0.0-alpha.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/dist/index.cjs CHANGED
@@ -25,28 +25,20 @@ __export(index_exports, {
25
25
  });
26
26
  module.exports = __toCommonJS(index_exports);
27
27
  var import_node_buffer = require("buffer");
28
- var import_serialize = require("@keyv/serialize");
29
28
  var import_lz4_napi = require("lz4-napi");
30
29
  var KeyvLz4 = class {
31
30
  constructor(dictionary) {
32
31
  this.dictionary = dictionary;
33
32
  }
34
33
  async compress(data) {
35
- return (0, import_lz4_napi.compress)(import_node_buffer.Buffer.from(data), this.getDictionary());
34
+ const compressed = await (0, import_lz4_napi.compress)(import_node_buffer.Buffer.from(data), this.getDictionary());
35
+ return compressed.toString("base64");
36
36
  }
37
37
  async decompress(data) {
38
- const value = await (0, import_lz4_napi.uncompress)(import_node_buffer.Buffer.from(data), this.getDictionary());
38
+ const buffer = import_node_buffer.Buffer.from(data, "base64");
39
+ const value = await (0, import_lz4_napi.uncompress)(buffer, this.getDictionary());
39
40
  return value.toString("utf8");
40
41
  }
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
42
  getDictionary() {
51
43
  if (this.dictionary) {
52
44
  return import_node_buffer.Buffer.from(this.dictionary);
package/dist/index.d.cts CHANGED
@@ -1,15 +1,8 @@
1
- type Serialize = {
2
- value: string;
3
- expires?: number;
4
- };
5
-
6
1
  declare class KeyvLz4 {
7
2
  private readonly dictionary?;
8
3
  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>;
4
+ compress(data: string): Promise<string>;
5
+ decompress(data: string): Promise<string>;
13
6
  private getDictionary;
14
7
  }
15
8
 
package/dist/index.d.ts CHANGED
@@ -1,15 +1,8 @@
1
- type Serialize = {
2
- value: string;
3
- expires?: number;
4
- };
5
-
6
1
  declare class KeyvLz4 {
7
2
  private readonly dictionary?;
8
3
  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>;
4
+ compress(data: string): Promise<string>;
5
+ decompress(data: string): Promise<string>;
13
6
  private getDictionary;
14
7
  }
15
8
 
package/dist/index.js CHANGED
@@ -1,27 +1,19 @@
1
1
  // src/index.ts
2
2
  import { Buffer } from "buffer";
3
- import { defaultDeserialize, defaultSerialize } from "@keyv/serialize";
4
3
  import { compress, uncompress } from "lz4-napi";
5
4
  var KeyvLz4 = class {
6
5
  constructor(dictionary) {
7
6
  this.dictionary = dictionary;
8
7
  }
9
8
  async compress(data) {
10
- return compress(Buffer.from(data), this.getDictionary());
9
+ const compressed = await compress(Buffer.from(data), this.getDictionary());
10
+ return compressed.toString("base64");
11
11
  }
12
12
  async decompress(data) {
13
- const value = await uncompress(Buffer.from(data), this.getDictionary());
13
+ const buffer = Buffer.from(data, "base64");
14
+ const value = await uncompress(buffer, this.getDictionary());
14
15
  return value.toString("utf8");
15
16
  }
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
17
  getDictionary() {
26
18
  if (this.dictionary) {
27
19
  return Buffer.from(this.dictionary);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keyv/compress-lz4",
3
- "version": "6.0.0-alpha.1",
3
+ "version": "6.0.0-alpha.3",
4
4
  "description": "lz4 compression for Keyv",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -43,18 +43,17 @@
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.1"
46
+ "lz4-napi": "^2.9.0"
48
47
  },
49
48
  "peerDependencies": {
50
- "keyv": "^6.0.0-alpha.1"
49
+ "keyv": "^6.0.0-alpha.3"
51
50
  },
52
51
  "devDependencies": {
53
52
  "@biomejs/biome": "^2.3.8",
54
53
  "@vitest/coverage-v8": "^4.0.14",
55
54
  "rimraf": "^6.1.2",
56
55
  "vitest": "^4.0.14",
57
- "@keyv/test-suite": "^6.0.0-alpha.1"
56
+ "@keyv/test-suite": "^6.0.0-alpha.3"
58
57
  },
59
58
  "tsd": {
60
59
  "directory": "test"