UNPKG

@opra/common

Version:
23 lines (22 loc) 737 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); if (!Array.prototype.findLast) { Array.prototype.findLast = function (predicate, thisArg) { const i = this.findLastIndex(predicate, thisArg); return i >= 0 ? this[i] : undefined; }; Array.prototype.findLastIndex = function (predicate, thisArg) { if (this == null) { throw new TypeError('this is null or not defined'); } const arr = Object(this); const len = this.length; thisArg = thisArg || this; for (let i = len - 1; i >= 0; i--) { if (predicate.call(thisArg, arr[i], i, arr)) { return i; } } return -1; }; }