UNPKG

iteragain

Version:

Javascript Iterable/Iterator/Generator-function utilities.

19 lines 726 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.reverse = reverse; const toIterator_1 = require("./toIterator"); const toIterableIterator_1 = require("./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. */ function reverse(arg) { let next; const it = (0, toIterator_1.default)(arg); const result = []; while (!(next = it.next()).done) result.unshift(next.value); return (0, toIterableIterator_1.default)(result); } exports.default = reverse; //# sourceMappingURL=reverse.js.map