lzma1 0.1.1 → 0.1.2
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/lib/index.d.ts +32 -1
- package/lib/index.js +44 -1
- package/lib/lzma.d.ts +2 -48
- package/lib/lzma.js +635 -601
- package/package.json +4 -3
package/lib/index.d.ts
CHANGED
|
@@ -3,4 +3,35 @@
|
|
|
3
3
|
* Copyright Filip Seman
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
import { LZMA } from "./lzma.js";
|
|
7
|
+
export { LZMA } from "./lzma.js";
|
|
8
|
+
/**
|
|
9
|
+
* Compresses data using LZMA algorithm
|
|
10
|
+
*
|
|
11
|
+
* @param data Data to compress - can be Uint8Array or ArrayBuffer
|
|
12
|
+
* @param mode Compression mode (1-9), defaults to 5
|
|
13
|
+
* @returns Compressed data as a byte array
|
|
14
|
+
*/
|
|
15
|
+
export declare function compress(data: Uint8Array | ArrayBuffer, mode?: keyof LZMA["CompressionModes"]): Uint8Array;
|
|
16
|
+
/**
|
|
17
|
+
* Compresses data using LZMA algorithm
|
|
18
|
+
*
|
|
19
|
+
* @param data String to compress
|
|
20
|
+
* @param mode Compression mode (1-9), defaults to 5
|
|
21
|
+
* @returns Compressed data as byte array
|
|
22
|
+
*/
|
|
23
|
+
export declare function compressString(data: string, mode?: keyof LZMA["CompressionModes"]): Uint8Array;
|
|
24
|
+
/**
|
|
25
|
+
* Decompresses LZMA compressed data
|
|
26
|
+
*
|
|
27
|
+
* @param data Compressed data as Uint8Array or ArrayBuffer
|
|
28
|
+
* @returns Decompressed data
|
|
29
|
+
*/
|
|
30
|
+
export declare function decompress(data: Uint8Array | ArrayBuffer): Uint8Array;
|
|
31
|
+
/**
|
|
32
|
+
* Decompresses LZMA compressed data
|
|
33
|
+
*
|
|
34
|
+
* @param data Compressed data as Uint8Array or ArrayBuffer
|
|
35
|
+
* @returns Decompressed data as string
|
|
36
|
+
*/
|
|
37
|
+
export declare function decompressString(data: Uint8Array | ArrayBuffer): string;
|
package/lib/index.js
CHANGED
|
@@ -3,4 +3,47 @@
|
|
|
3
3
|
* Copyright Filip Seman
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
import { LZMA } from "./lzma.js";
|
|
7
|
+
export { LZMA } from "./lzma.js";
|
|
8
|
+
/**
|
|
9
|
+
* Compresses data using LZMA algorithm
|
|
10
|
+
*
|
|
11
|
+
* @param data Data to compress - can be Uint8Array or ArrayBuffer
|
|
12
|
+
* @param mode Compression mode (1-9), defaults to 5
|
|
13
|
+
* @returns Compressed data as a byte array
|
|
14
|
+
*/
|
|
15
|
+
export function compress(data, mode = 5) {
|
|
16
|
+
const lzma = new LZMA();
|
|
17
|
+
return new Uint8Array(lzma.compress(data, mode));
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Compresses data using LZMA algorithm
|
|
21
|
+
*
|
|
22
|
+
* @param data String to compress
|
|
23
|
+
* @param mode Compression mode (1-9), defaults to 5
|
|
24
|
+
* @returns Compressed data as byte array
|
|
25
|
+
*/
|
|
26
|
+
export function compressString(data, mode = 5) {
|
|
27
|
+
const lzma = new LZMA();
|
|
28
|
+
return new Uint8Array(lzma.compressString(data, mode));
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Decompresses LZMA compressed data
|
|
32
|
+
*
|
|
33
|
+
* @param data Compressed data as Uint8Array or ArrayBuffer
|
|
34
|
+
* @returns Decompressed data
|
|
35
|
+
*/
|
|
36
|
+
export function decompress(data) {
|
|
37
|
+
const lzma = new LZMA();
|
|
38
|
+
return new Uint8Array(lzma.decompress(data));
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Decompresses LZMA compressed data
|
|
42
|
+
*
|
|
43
|
+
* @param data Compressed data as Uint8Array or ArrayBuffer
|
|
44
|
+
* @returns Decompressed data as string
|
|
45
|
+
*/
|
|
46
|
+
export function decompressString(data) {
|
|
47
|
+
const lzma = new LZMA();
|
|
48
|
+
return lzma.decompressString(data);
|
|
49
|
+
}
|
package/lib/lzma.d.ts
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Converts a number to a signed 8-bit integer using DataView.
|
|
3
|
-
*
|
|
4
|
-
* Previously, this was done with bitwise operations (value << 24 >> 24), but
|
|
5
|
-
* that approach was obscure and hard to understand. Using DataView improves
|
|
6
|
-
* readability and ensures correct 8-bit conversion.
|
|
7
|
-
*/
|
|
8
|
-
export declare function toSigned8bit(value: number): number;
|
|
9
|
-
/**
|
|
10
|
-
* Converts a number to a signed 16-bit integer using DataView.
|
|
11
|
-
*
|
|
12
|
-
* Previously, this was done with bitwise operations (value << 16 >> 16), but
|
|
13
|
-
* that approach was obscure and hard to understand. Using DataView improves
|
|
14
|
-
* readability and ensures correct 16-bit conversion.
|
|
15
|
-
*/
|
|
16
|
-
export declare function toSigned16bit(value: number): number;
|
|
17
1
|
export declare class LZMA {
|
|
18
2
|
#private;
|
|
19
3
|
readonly CompressionModes: {
|
|
@@ -75,38 +59,8 @@ export declare class LZMA {
|
|
|
75
59
|
InitBitModels(probs: number[]): void;
|
|
76
60
|
GetPrice(Prob: number, symbol: number): number;
|
|
77
61
|
encodeString(inputString: string): number[];
|
|
78
|
-
compress(data: Uint8Array | ArrayBuffer, mode?: keyof typeof this.CompressionModes):
|
|
79
|
-
compressString(data: string, mode?: keyof typeof this.CompressionModes):
|
|
62
|
+
compress(data: Uint8Array | ArrayBuffer, mode?: keyof typeof this.CompressionModes): Int8Array;
|
|
63
|
+
compressString(data: string, mode?: keyof typeof this.CompressionModes): Int8Array;
|
|
80
64
|
decompress(bytearray: Uint8Array | ArrayBuffer): number[];
|
|
81
65
|
decompressString(bytearray: Uint8Array | ArrayBuffer): string;
|
|
82
66
|
}
|
|
83
|
-
/**
|
|
84
|
-
* Compresses data using LZMA algorithm
|
|
85
|
-
*
|
|
86
|
-
* @param data Data to compress - can be Uint8Array or ArrayBuffer
|
|
87
|
-
* @param mode Compression mode (1-9), defaults to 5
|
|
88
|
-
* @returns Compressed data as a byte array
|
|
89
|
-
*/
|
|
90
|
-
export declare function compress(data: Uint8Array | ArrayBuffer, mode?: keyof LZMA["CompressionModes"]): Uint8Array;
|
|
91
|
-
/**
|
|
92
|
-
* Compresses data using LZMA algorithm
|
|
93
|
-
*
|
|
94
|
-
* @param data String to compress
|
|
95
|
-
* @param mode Compression mode (1-9), defaults to 5
|
|
96
|
-
* @returns Compressed data as byte array
|
|
97
|
-
*/
|
|
98
|
-
export declare function compressString(data: string, mode?: keyof LZMA["CompressionModes"]): Uint8Array;
|
|
99
|
-
/**
|
|
100
|
-
* Decompresses LZMA compressed data
|
|
101
|
-
*
|
|
102
|
-
* @param data Compressed data as Uint8Array or ArrayBuffer
|
|
103
|
-
* @returns Decompressed data
|
|
104
|
-
*/
|
|
105
|
-
export declare function decompress(data: Uint8Array | ArrayBuffer): Uint8Array;
|
|
106
|
-
/**
|
|
107
|
-
* Decompresses LZMA compressed data
|
|
108
|
-
*
|
|
109
|
-
* @param data Compressed data as Uint8Array or ArrayBuffer
|
|
110
|
-
* @returns Decompressed data as string
|
|
111
|
-
*/
|
|
112
|
-
export declare function decompressString(data: Uint8Array | ArrayBuffer): string;
|