UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

18 lines (17 loc) • 781 B
//#region packages/normalization-core/src/number-coercion.ts function asFiniteNumber(e) { return typeof e === "number" && Number.isFinite(e) ? e : void 0; } /** Conservative upper bound for Node timer delays. */ const MAX_TIMER_TIMEOUT_MS = 2147e6; /** Timer bound expressed in whole seconds for env/config inputs. */ const MAX_TIMER_TIMEOUT_SECONDS = Math.floor(MAX_TIMER_TIMEOUT_MS / 1e3); /** Resolves arbitrary timeout input with fallback and minimum timer bounds. */ function resolveTimerTimeoutMs(e, t, n = 1) { const r = asFiniteNumber(e) ?? asFiniteNumber(t); const i = Math.max(0, Math.floor(n)); if (r === void 0) return i; return Math.min(Math.max(Math.floor(r), i), MAX_TIMER_TIMEOUT_MS); } //#endregion export { resolveTimerTimeoutMs as n, asFiniteNumber as t };