From 4a5df1c5684b1788dee733dc0e13c4627c58a1bc Mon Sep 17 00:00:00 2001 From: Youzini-afk <13153778771cx@gmail.com> Date: Wed, 15 Apr 2026 16:29:36 +0800 Subject: [PATCH] fix: restore non-negative count normalizer --- sync/bme-db.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sync/bme-db.js b/sync/bme-db.js index 5eb99a2..3abc6c7 100644 --- a/sync/bme-db.js +++ b/sync/bme-db.js @@ -101,6 +101,14 @@ function normalizeTimestamp(value, fallbackValue = Date.now()) { return Math.floor(Number(fallbackValue) || Date.now()); } +function normalizeNonNegativeInteger(value, fallback = 0) { + const parsed = Number(value); + if (!Number.isFinite(parsed)) { + return Math.max(0, Math.floor(Number(fallback) || 0)); + } + return Math.max(0, Math.floor(parsed)); +} + function toPlainData(value, fallbackValue = null) { if (value == null) { return fallbackValue;