File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 134134 "loglevel" : " ^1.8.0" ,
135135 "loglevel-message-prefix" : " ^3.0.0" ,
136136 "lz-string" : " ^1.4.4" ,
137+ "lz4js" : " ^0.2.0" ,
137138 "markdown-it" : " ^13.0.1" ,
138139 "moment" : " ^2.29.3" ,
139140 "moment-timezone" : " ^0.5.34" ,
Original file line number Diff line number Diff line change 333333 " LZString Decompress" ,
334334 " LZString Compress" ,
335335 " LZMA Decompress" ,
336- " LZMA Compress"
336+ " LZMA Compress" ,
337+ " LZ4 Decompress" ,
338+ " LZ4 Compress"
337339 ]
338340 },
339341 {
Original file line number Diff line number Diff line change 1+ /**
2+ * @author n1474335 [n1474335@gmail.com]
3+ * @copyright Crown Copyright 2022
4+ * @license Apache-2.0
5+ */
6+
7+ import Operation from "../Operation.mjs" ;
8+ import lz4 from "lz4js" ;
9+
10+ /**
11+ * LZ4 Compress operation
12+ */
13+ class LZ4Compress extends Operation {
14+
15+ /**
16+ * LZ4Compress constructor
17+ */
18+ constructor ( ) {
19+ super ( ) ;
20+
21+ this . name = "LZ4 Compress" ;
22+ this . module = "Compression" ;
23+ this . description = "LZ4 is a lossless data compression algorithm that is focused on compression and decompression speed. It belongs to the LZ77 family of byte-oriented compression schemes." ;
24+ this . infoURL = "https://wikipedia.org/wiki/LZ4_(compression_algorithm)" ;
25+ this . inputType = "ArrayBuffer" ;
26+ this . outputType = "ArrayBuffer" ;
27+ this . args = [ ] ;
28+ }
29+
30+ /**
31+ * @param {ArrayBuffer } input
32+ * @param {Object[] } args
33+ * @returns {ArrayBuffer }
34+ */
35+ run ( input , args ) {
36+ const inBuf = new Uint8Array ( input ) ;
37+ const compressed = lz4 . compress ( inBuf ) ;
38+ return compressed . buffer ;
39+ }
40+
41+ }
42+
43+ export default LZ4Compress ;
Original file line number Diff line number Diff line change 1+ /**
2+ * @author n1474335 [n1474335@gmail.com]
3+ * @copyright Crown Copyright 2022
4+ * @license Apache-2.0
5+ */
6+
7+ import Operation from "../Operation.mjs" ;
8+ import lz4 from "lz4js" ;
9+
10+ /**
11+ * LZ4 Decompress operation
12+ */
13+ class LZ4Decompress extends Operation {
14+
15+ /**
16+ * LZ4Decompress constructor
17+ */
18+ constructor ( ) {
19+ super ( ) ;
20+
21+ this . name = "LZ4 Decompress" ;
22+ this . module = "Compression" ;
23+ this . description = "LZ4 is a lossless data compression algorithm that is focused on compression and decompression speed. It belongs to the LZ77 family of byte-oriented compression schemes." ;
24+ this . infoURL = "https://wikipedia.org/wiki/LZ4_(compression_algorithm)" ;
25+ this . inputType = "ArrayBuffer" ;
26+ this . outputType = "ArrayBuffer" ;
27+ this . args = [ ] ;
28+ }
29+
30+ /**
31+ * @param {ArrayBuffer } input
32+ * @param {Object[] } args
33+ * @returns {ArrayBuffer }
34+ */
35+ run ( input , args ) {
36+ const inBuf = new Uint8Array ( input ) ;
37+ const decompressed = lz4 . decompress ( inBuf ) ;
38+ return decompressed . buffer ;
39+ }
40+
41+ }
42+
43+ export default LZ4Decompress ;
Original file line number Diff line number Diff line change @@ -75,4 +75,34 @@ TestRegister.addTests([
7575 }
7676 ] ,
7777 } ,
78+ {
79+ name : "LZ4 Compress" ,
80+ input : "The cat sat on the mat." ,
81+ expectedOutput : "04224d184070df170000805468652063617420736174206f6e20746865206d61742e00000000" ,
82+ recipeConfig : [
83+ {
84+ "op" : "LZ4 Compress" ,
85+ "args" : [ ]
86+ } ,
87+ {
88+ "op" : "To Hex" ,
89+ "args" : [ "None" , 0 ]
90+ }
91+ ] ,
92+ } ,
93+ {
94+ name : "LZ4 Decompress" ,
95+ input : "04224d184070df170000805468652063617420736174206f6e20746865206d61742e00000000" ,
96+ expectedOutput : "The cat sat on the mat." ,
97+ recipeConfig : [
98+ {
99+ "op" : "From Hex" ,
100+ "args" : [ "None" ]
101+ } ,
102+ {
103+ "op" : "LZ4 Decompress" ,
104+ "args" : [ ]
105+ }
106+ ] ,
107+ } ,
78108] ) ;
You can’t perform that action at this time.
0 commit comments