mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-17 22:17:28 +00:00
15 lines
528 B
TypeScript
15 lines
528 B
TypeScript
export function isRecord(value: unknown): value is Record<string, unknown> {
|
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
}
|
|
|
|
export function isNonEmptyString(value: unknown): value is string {
|
|
return typeof value === "string" && value.trim().length > 0;
|
|
}
|
|
|
|
export function normalizePositiveInt(value: unknown, fallback: number): number {
|
|
if (typeof value === "number" && Number.isFinite(value)) {
|
|
return Math.max(1, Math.floor(value));
|
|
}
|
|
return Math.max(1, Math.floor(fallback));
|
|
}
|