iteragain
Version:
Javascript Iterable/Iterator/Generator-function utilities.
16 lines • 582 B
JavaScript
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.unshift(next.value);
return toIterableIterator(result);
}
export default reverse;
//# sourceMappingURL=reverse.js.map