Skip to content

Commit

Permalink
perf: 优化isPromise的实现方式
Browse files Browse the repository at this point in the history
  • Loading branch information
vtrbo committed Jun 26, 2024
1 parent 4ab30f3 commit 8f6e47c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/is/src/isPromise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { isObject } from './isObject'
*/
export function isPromise<T>(data: unknown): data is Promise<T> {
return (
isObject(data)
&& isFunction((data as any).then)
&& isFunction((data as any).catch)
isObject<{ then: Function, catch: Function }>(data)
&& isFunction(data.then)
&& isFunction(data.catch)
)
}

0 comments on commit 8f6e47c

Please sign in to comment.