iteragain
Version:
Javascript Iterable/Iterator/Generator-function utilities.
17 lines • 597 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) {
var next;
var it = toIterator(arg);
var result = [];
while (!(next = it.next()).done)
result.push(next.value);
result.reverse();
return toIterableIterator(result);
}
export default reverse;
//# sourceMappingURL=reverse.js.map