(value: unknown)
| 23 | // unit: MINUTES accepts either a bare number (minutes) or a string with |
| 24 | // an optional unit suffix (d/h/m/s). Returns days, or undefined. |
| 25 | export function parseYarnDuration(value: unknown): number | undefined { |
| 26 | if (typeof value === 'number') |
| 27 | return value > 0 ? value / 1440 : undefined |
| 28 | if (typeof value !== 'string') |
| 29 | return undefined |
| 30 | const m = value.trim().match(/^(\d+(?:\.\d+)?)\s*([dhms]?)$/i) |
| 31 | if (!m) |
| 32 | return undefined |
| 33 | const num = Number.parseFloat(m[1]) |
| 34 | if (!Number.isFinite(num) || num <= 0) |
| 35 | return undefined |
| 36 | switch ((m[2] || 'm').toLowerCase()) { |
| 37 | case 'd': return num |
| 38 | case 'h': return num / 24 |
| 39 | case 'm': return num / 1440 |
| 40 | case 's': return num / 86400 |
| 41 | default: return undefined |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | async function readYamlTop(filepath: string | undefined): Promise<Record<string, any> | null> { |
| 46 | if (!filepath) |
no outgoing calls
no test coverage detected
searching dependent graphs…