From 7be0d0cb3b4cd7812ec4803488c83e1e4006bce9 Mon Sep 17 00:00:00 2001 From: MysteryCode Date: Wed, 13 Nov 2024 13:59:09 +0100 Subject: [PATCH] fix switch back to `0` in HTP merging (#65) --- src/merging.ts | 2 +- test/merging.test.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/merging.ts b/src/merging.ts index 39e695d..a72a401 100644 --- a/src/merging.ts +++ b/src/merging.ts @@ -236,7 +236,7 @@ export class MergingReceiver extends Receiver { ) { for (let ch = 1; ch <= 512; ch += 1) { const newValue = packet.payload[ch] || 0; - if ((mergedData[ch] ?? 0) < newValue) { + if ((mergedData[ch] ?? 0) <= newValue) { mergedData[ch] = newValue; } } diff --git a/test/merging.test.ts b/test/merging.test.ts index 94dd4c2..5bf90f3 100644 --- a/test/merging.test.ts +++ b/test/merging.test.ts @@ -42,6 +42,8 @@ describe('HTP', () => { }), }, }); + deleteZeros(merged); + expect(merged).toStrictEqual({ // HTP applies to the whole packet, so channel 4 is 0, instead of 204 // referenceData is irrelevant for HTP, so channel 5 is 0, instead of 5 @@ -66,6 +68,8 @@ describe('HTP', () => { }), }, }); + deleteZeros(merged); + expect(merged).toStrictEqual({ 1: 201, 2: 202,