sequency
Version:
Functional sequences for processing iterable data in JavaScript
27 lines • 860 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.IndexOfLast = void 0;
var IndexOfLast = /** @class */ (function () {
function IndexOfLast() {
}
/**
* Returns the zero-based index of the last element matching the given `predicate` or -1 if no element matches
* the predicate.
*
* @param {(value: T) => boolean} predicate
* @returns {number}
*/
IndexOfLast.prototype.indexOfLast = function (predicate) {
var index = 0;
var result = -1;
for (var item = this.iterator.next(); !item.done; item = this.iterator.next()) {
if (predicate(item.value)) {
result = index;
}
index++;
}
return result;
};
return IndexOfLast;
}());
exports.IndexOfLast = IndexOfLast;
//# sourceMappingURL=indexOfLast.js.map