is-promise.js 334 B

12345678910111213
  1. /**
  2. * Check whether a value is a Promise-like
  3. * instance. Recognizes both native promises
  4. * and third-party promise libraries.
  5. *
  6. * @param {*} value
  7. * @returns {boolean}
  8. */
  9. export function isPromise(value) {
  10. if (!value) return false;
  11. if (typeof value !== 'object') return false;
  12. return typeof value.then === 'function';
  13. }