Skip to content

Home

Generator to array

Converts the output of a generator function to an array.

const generatorToArray = gen => [...gen];

const s = new Set([1, 2, 1, 3, 1, 4]);
generatorToArray(s.entries()); // [[ 1, 1 ], [ 2, 2 ], [ 3, 3 ], [ 4, 4 ]]

More like this

Start typing a keyphrase to see matching snippets.