Skip to content

unctionjs/fromIteratorToArray

Repository files navigation

@unction/fromIteratorToArray

Tests Stability Dependencies

Map<A, B> => Array<[A, B]>

Takes an Iterator (SetIterator, MapIterator, etc) and turns it into an array.

fromIteratorToArray(new Set([1, 2, 3]).entries()) // [[1, 1], [2, 2], [3, 3]]
fromIteratorToArray(new Map([["aaa", "a"], ["bbb", "b"], ["ccc", "c"]]).entries()) // [["aaa", "a"], ["bbb", "b"], ["ccc", "c"]]