sequency
Version:
Functional sequences for processing iterable data in JavaScript
33 lines • 1.03 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.ToArray = void 0;
var ToArray = /** @class */ (function () {
function ToArray() {
}
/**
* Returns all elements of the sequence as array. If an `array` is passed
* the elements are appended to the end of the array.
*
* @param {Array<T>} array
* @returns {Array<T>}
*/
ToArray.prototype.toArray = function (array) {
var result = array || [];
for (var item = this.iterator.next(); !item.done; item = this.iterator.next()) {
result.push(item.value);
}
return result;
};
/**
* Returns all elements of the sequence as array. If an `array` is passed
* the elements are appended to the end of the array.
*
* @param {Array<T>} array
* @returns {Array<T>}
*/
ToArray.prototype.toList = function (array) {
return this.toArray(array);
};
return ToArray;
}());
exports.ToArray = ToArray;
//# sourceMappingURL=toArray.js.map