UNPKG

msw

Version:

The industry standard for API mocking in JavaScript.

17 lines (15 loc) • 369 B
/** * Determines if the given function is an iterator. */ export function isIterable<IteratorType>( fn: any, ): fn is | Iterable<IteratorType, IteratorType, IteratorType> | AsyncIterable<IteratorType, IteratorType, IteratorType> { if (!fn) { return false } return ( Reflect.has(fn, Symbol.iterator) || Reflect.has(fn, Symbol.asyncIterator) ) }