isPromise.js.flow 348 B

123456789101112
  1. // @flow strict
  2. /**
  3. * Returns true if the value acts like a Promise, i.e. has a "then" function,
  4. * otherwise returns false.
  5. */
  6. declare function isPromise(value: mixed): boolean %checks(value instanceof
  7. Promise);
  8. // eslint-disable-next-line no-redeclare
  9. export default function isPromise(value) {
  10. return typeof value?.then === 'function';
  11. }