Skip to content

isAsyncIterable

Determine if a value is an async iterable

162 bytes
currently in beta

Usage

Returns a boolean if the given value is an object with a [Symbol.asyncIterator] method.

import { isAsyncIterable } from 'radashi'
isAsyncIterable(
(async function* () {
yield 1
})(),
)
// => true
isAsyncIterable([1, 2, 3])
// => false

If used in an environment where Symbol.asyncIterator is not available, the function will use Symbol.for('Symbol.asyncIterator') as a fallback.