task-6: isTerminalStatus() 终态判定(默认 SUCCESS/FAILED,extras 扩展且归一化,空值非终态)
This commit is contained in:
@@ -8,3 +8,19 @@ export function normalizeStatus(raw: string | null | undefined): string {
|
||||
}
|
||||
return trimmed.toUpperCase().replace(/[\s-]+/g, '_')
|
||||
}
|
||||
|
||||
export function isTerminalStatus(
|
||||
status: string | null | undefined,
|
||||
extras?: string[],
|
||||
): boolean {
|
||||
const normalized = normalizeStatus(status)
|
||||
if (!normalized) {
|
||||
return false
|
||||
}
|
||||
const terminalSet = new Set([
|
||||
'SUCCESS',
|
||||
'FAILED',
|
||||
...(extras ?? []).map((extra) => normalizeStatus(extra)),
|
||||
])
|
||||
return terminalSet.has(normalized)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user