From 14b69e714ae5c3101f61dc68b7720438bf5b2181 Mon Sep 17 00:00:00 2001 From: Juhani Pirttilahti Date: Fri, 24 Feb 2023 01:29:26 +0200 Subject: [PATCH] Return null if CIF_speed is not defined (#5) --- models/vstp.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/models/vstp.js b/models/vstp.js index bf359b2..b28b770 100644 --- a/models/vstp.js +++ b/models/vstp.js @@ -34,7 +34,12 @@ function parsets(ts) { } function parsespeed(CIF_speed) { - const speed = +CIF_speed; + // set null if attribute is missing + if (CIF_speed === undefined) { + return null; + } + let speed = parseInt(CIF_speed) || 0; + // fix speed values in incorrect unit switch (speed) { case 22: return 10;