UNPKG

iteragain

Version:

Javascript Iterable/Iterator/Generator-function utilities.

17 lines 601 B
import toIterator from './toIterator'; import toIterableIterator from './toIterableIterator'; /** * Reverses the input iterator's order. Note that in order to reverse, it will attempt to iterate fully once, which * could cause significant memory usage. So because of this, only use on finite iterators. */ export function reverse(arg) { let next; const it = toIterator(arg); const result = []; while (!(next = it.next()).done) result.push(next.value); result.reverse(); return toIterableIterator(result); } export default reverse; //# sourceMappingURL=reverse.js.map