-
-
Notifications
You must be signed in to change notification settings - Fork 0
iterator
Nicholas Berlette edited this page Jun 19, 2025
·
1 revision
function isIterator<T>(it: unknown): it is Iterator<T>;
Check if the given value is an iterator object. This includes arrays, maps,
sets, and any other value with a .next
method.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is an iterator, false
otherwise.
Iterables
import { isIterator } from "jsr:@nick/is/iterator";
const iterable = [1, 2, 3];
const iterator = iterable[Symbol.iterator]();
console.log(isIterator(iterator)); // true
console.log(isIterator(iterable)); // false