map iterator - nberlette/is GitHub Wiki
function isMapIterator<K, V>(it: unknown): it is MapIterator<K, V>;
Check if the given value is a map iterator, which is an iterable iterator that
yields key-value pairs from a Map object. This is the type of object returned by
the Map.prototype.entries
and Map.prototype[Symbol.iterator]
methods.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a map iterator, false
otherwise.
Iterables
import { isMapIterator } from "jsr:@nick/is/map-iterator";
const map = new Map([["foo", 1], ["bar", 2]]);
const iterator = map.entries();
console.log(isMapIterator(iterator)); // true
console.log(isMapIterator(map)); // false
Represents a map iterator.
K
V
readonly [Symbol.toStringTag]: "Map Iterator" | "Map Entries";