Files
tasq/node_modules/@ai-sdk/provider-utils/src/remove-undefined-entries.ts
T
2026-04-09 19:01:53 +08:00

13 lines
477 B
TypeScript

/**
* Removes entries from a record where the value is null or undefined.
* @param record - The input object whose entries may be null or undefined.
* @returns A new object containing only entries with non-null and non-undefined values.
*/
export function removeUndefinedEntries<T>(
record: Record<string, T | undefined>,
): Record<string, T> {
return Object.fromEntries(
Object.entries(record).filter(([_key, value]) => value != null),
) as Record<string, T>;
}