@arizeai/phoenix-evals
Version:
A library for running evaluations for AI use cases
15 lines (14 loc) • 448 B
text/typescript
/**
* Type guard for if a function is a Promise
* @param value
* @returns true if it is a Promise
*/
export function isPromise<T = unknown>(value: unknown): value is Promise<T> {
return (
!!value &&
// eslint-disable-next-line @typescript-eslint/no-explicit-any
typeof (value as any)?.then === "function" &&
// eslint-disable-next-line @typescript-eslint/no-explicit-any
typeof (value as any)?.catch === "function"
);
}