(value)
| 14 | * @returns {number|null} Normalized timestamp in milliseconds or null if invalid. |
| 15 | */ |
| 16 | const normalizeTimestamp = (value) => { |
| 17 | if (value == null) { |
| 18 | return null; |
| 19 | } |
| 20 | |
| 21 | if (typeof value === "string") { |
| 22 | const trimmed = value.trim(); |
| 23 | if (trimmed === "") { |
| 24 | return null; |
| 25 | } |
| 26 | const parsed = Number(trimmed); |
| 27 | return Number.isFinite(parsed) ? parsed : null; |
| 28 | } |
| 29 | |
| 30 | if (typeof value === "number") { |
| 31 | return Number.isFinite(value) ? value : null; |
| 32 | } |
| 33 | |
| 34 | if (value?.toMillis && typeof value.toMillis === "function") { |
| 35 | return value.toMillis(); |
| 36 | } |
| 37 | |
| 38 | return null; |
| 39 | }; |
| 40 | |
| 41 | /** |
| 42 | * Determines the timestamp to persist in the `lastOooUntil` field based on state transitions. |
no outgoing calls
no test coverage detected