A toolbox to check if an object is iterable, an iterator or a generator, etc.
npm i check-iterable
import * as CheckIterable from "https://deno.land/x/check_iterable/index.js";
isIterable(obj: any): boolean
Checks if the given object is an Iterable (implemented@@iterator
).isAsyncIterable(obj: any): boolean
Checks if the given object is an AsyncIterable (implemented@@asyncIterator
).isIteratorLike(obj: any): boolean
Checks if the given object is an IteratorLike (implementednext
).isIterableIterator(obj: any): boolean
Checks if the given object is an IterableIterator (implemented both@@iterator
andnext
).isAsyncIterableIterator(obj: any): boolean
Checks if the given object is an AsyncIterableIterator (implemented both@@asyncIterator
andnext
).isGenerator(obj: any): boolean
Checks if the given object is a Generator.isAsyncGenerator(obj: any): boolean
Checks if the given object is an AsyncGenerator.
Note:
These functions are designed to test whether an object suits the specifications suggested on MDN in sloppy mode, go to MDN for more details.