sequency
Version:
Functional sequences for processing iterable data in JavaScript
24 lines • 741 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.MaxWith = void 0;
var MaxWith = /** @class */ (function () {
function MaxWith() {
}
/**
* Returns the maximum element of the sequence by evaluating the given `compare`
* function or `null` if sequence is empty.
*
* @returns {T}
*/
MaxWith.prototype.maxWith = function (compare) {
var max = null;
for (var item = this.iterator.next(); !item.done; item = this.iterator.next()) {
if (max == null || compare(item.value, max) > 0) {
max = item.value;
}
}
return max;
};
return MaxWith;
}());
exports.MaxWith = MaxWith;
//# sourceMappingURL=maxWith.js.map