(s: string)
| 11 | */ |
| 12 | |
| 13 | export function parseDuration(s: string): number | null { |
| 14 | const re = /^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?$/ |
| 15 | const m = re.exec(s.trim()) |
| 16 | if (!m) return null |
| 17 | const h = Number(m[1] ?? 0) |
| 18 | const min = Number(m[2] ?? 0) |
| 19 | const sec = Number(m[3] ?? 0) |
| 20 | if (h === 0 && min === 0 && sec === 0) return null |
| 21 | return (h * 3600 + min * 60 + sec) * 1000 |
| 22 | } |
no outgoing calls
no test coverage detected