Skip to content

Commit 31ca9d3

Browse files
authored
moving from zlib to minizlib (#57)
1 parent 38bfdc8 commit 31ca9d3

File tree

4 files changed

+170
-287
lines changed

4 files changed

+170
-287
lines changed

lib/utils/miam.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,5 @@ test('v1, compressed, acars, incomplete', () => {
5959
expect(decodeResult.message.data.acars.label).toBe('H1');
6060
expect(decodeResult.message.data.acars.sublabel).toBe('DF');
6161
expect(decodeResult.message.data.acars.mfi).toBe(undefined);
62-
expect(decodeResult.message.data.acars.text).toBe(undefined);
62+
expect(decodeResult.message.data.acars.text).toBe('A350,000130,1,1,TB000000/REP019,24,02;H01,019,24,02,6400,00175,B-18910,3,0,03,11,19,08,07,01,070/H02,NZAA YBBN,CAL054 ,S');
6363
})

lib/utils/miam.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as Base85 from 'base85';
2-
import * as Zlib from 'zlib';
2+
import * as zlib from "minizlib";
33

44
enum MIAMFid {
55
SingleTransfer = 'T',
@@ -398,7 +398,10 @@ export class MIAMCoreUtils {
398398
if (body !== undefined && body.length > 0) {
399399
if ([MIAMCoreV1Compression.Deflate, MIAMCoreV2Compression.Deflate].indexOf(pduCompression) >= 0) {
400400
try {
401-
pduData = Zlib.inflateRawSync(body, { windowBits: 15 });
401+
const decompress = new zlib.InflateRaw({windowBits: 15});
402+
decompress.write(body);
403+
decompress.flush(zlib.constants.Z_SYNC_FLUSH);
404+
pduData = decompress.read();
402405
} catch (e) {
403406
pduErrors.push('Inflation failed for body: ' + e);
404407
}

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@
2828
"license": "UNLICENSED",
2929
"dependencies": {
3030
"@types/node": "^22.0.0",
31-
"base85": "^3.1.0"
31+
"base85": "^3.1.0",
32+
"minizlib": "^2.1.2"
3233
},
3334
"devDependencies": {
3435
"@babel/core": "^7.18.13",
3536
"@babel/preset-env": "^7.18.10",
3637
"@babel/preset-typescript": "^7.18.6",
3738
"@types/jest": "^28.1.7",
39+
"@types/minizlib": "^2.1.7",
3840
"babel-jest": "^29.7.0",
3941
"jest": "^28.1.3",
4042
"ts-jest": "^28.0.8",

0 commit comments

Comments
 (0)