For a JavaScript array, the includes(value) function returns true, if and only if the array contains the value.
What is a good and performant equivalent to check, whether a value is included in an iterator (e.g. map.values())?
First approach (maybe not the most performant one):
Array.from(it).includes(value)
Second approach (not that short):
const iteratorIncludes = (it, value) => {
for (x of it) {
if (x === value) return true
}
return false
}
iteratorIncludes(it, value)