Skip to content

Commit

Permalink
moving from zlib to minizlib (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
makrsmark authored Jul 29, 2024
1 parent 38bfdc8 commit 31ca9d3
Show file tree
Hide file tree
Showing 4 changed files with 170 additions and 287 deletions.
2 changes: 1 addition & 1 deletion lib/utils/miam.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,5 @@ test('v1, compressed, acars, incomplete', () => {
expect(decodeResult.message.data.acars.label).toBe('H1');
expect(decodeResult.message.data.acars.sublabel).toBe('DF');
expect(decodeResult.message.data.acars.mfi).toBe(undefined);
expect(decodeResult.message.data.acars.text).toBe(undefined);
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');
})
7 changes: 5 additions & 2 deletions lib/utils/miam.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as Base85 from 'base85';
import * as Zlib from 'zlib';
import * as zlib from "minizlib";

enum MIAMFid {
SingleTransfer = 'T',
Expand Down Expand Up @@ -398,7 +398,10 @@ export class MIAMCoreUtils {
if (body !== undefined && body.length > 0) {
if ([MIAMCoreV1Compression.Deflate, MIAMCoreV2Compression.Deflate].indexOf(pduCompression) >= 0) {
try {
pduData = Zlib.inflateRawSync(body, { windowBits: 15 });
const decompress = new zlib.InflateRaw({windowBits: 15});
decompress.write(body);
decompress.flush(zlib.constants.Z_SYNC_FLUSH);
pduData = decompress.read();
} catch (e) {
pduErrors.push('Inflation failed for body: ' + e);
}
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@
"license": "UNLICENSED",
"dependencies": {
"@types/node": "^22.0.0",
"base85": "^3.1.0"
"base85": "^3.1.0",
"minizlib": "^2.1.2"
},
"devDependencies": {
"@babel/core": "^7.18.13",
"@babel/preset-env": "^7.18.10",
"@babel/preset-typescript": "^7.18.6",
"@types/jest": "^28.1.7",
"@types/minizlib": "^2.1.7",
"babel-jest": "^29.7.0",
"jest": "^28.1.3",
"ts-jest": "^28.0.8",
Expand Down
Loading

0 comments on commit 31ca9d3

Please sign in to comment.