Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions apps/meteor/client/lib/convertTimeUnit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@ export enum TIMEUNIT {
}

export const isValidTimespan = (timespan: number): boolean => {
if (Number.isNaN(timespan)) {
// Fast-path type check to preserve original Number.isFinite behavior for non-number inputs
if (typeof timespan !== 'number') {
return false;
}

if (!Number.isFinite(timespan)) {
// NaN check without calling Number.isNaN
if (timespan !== timespan) {
return false;
}

// Infinity checks without calling Number.isFinite
if (timespan === Infinity || timespan === -Infinity) {
return false;
}

Expand Down