UNPKG

vtils

Version:

一个面向业务的 JavaScript/TypeScript 实用程序库。

17 lines (16 loc) 402 B
"use strict"; exports.__esModule = true; exports.isPromiseLike = isPromiseLike; /** * 检查 `value` 是否像 `Promise`。 * * @param value 要检查的值 * @returns 返回检查结果 * @example * ```typescript * isPromiseLike(Promise.resolve()) // => true * ``` */ function isPromiseLike(value) { return typeof value === 'object' && value !== null && typeof value.then === 'function'; }