mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 04:51:25 +00:00
refactor: dedupe provider usage auth/fetch logic and expand coverage
This commit is contained in:
@@ -16,6 +16,19 @@ export async function fetchJson(
|
||||
}
|
||||
}
|
||||
|
||||
export function parseFiniteNumber(value: unknown): number | undefined {
|
||||
if (typeof value === "number" && Number.isFinite(value)) {
|
||||
return value;
|
||||
}
|
||||
if (typeof value === "string") {
|
||||
const parsed = Number.parseFloat(value);
|
||||
if (Number.isFinite(parsed)) {
|
||||
return parsed;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
type BuildUsageHttpErrorSnapshotOptions = {
|
||||
provider: UsageProviderId;
|
||||
status: number;
|
||||
|
||||
Reference in New Issue
Block a user