isAsyncIterable.js.flow 528 B

1234567891011121314
  1. // @flow strict
  2. import { SYMBOL_ASYNC_ITERATOR } from '../polyfills/symbols';
  3. /**
  4. * Returns true if the provided object implements the AsyncIterator protocol via
  5. * either implementing a `Symbol.asyncIterator` or `"@@asyncIterator"` method.
  6. */
  7. declare function isAsyncIterable(value: mixed): boolean %checks(value instanceof
  8. AsyncIterable);
  9. // eslint-disable-next-line no-redeclare
  10. export default function isAsyncIterable(maybeAsyncIterable) {
  11. return typeof maybeAsyncIterable?.[SYMBOL_ASYNC_ITERATOR] === 'function';
  12. }