MCPcopy
hub / github.com/antfu-collective/taze / parseYarnDuration

Function parseYarnDuration

src/utils/detectMaturity.ts:25–43  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

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.
25export 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
45async function readYamlTop(filepath: string | undefined): Promise<Record<string, any> | null> {
46 if (!filepath)

Callers 2

detectMaturityConfigFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…