21 lines
474 B
JavaScript
21 lines
474 B
JavaScript
import { createMethodShim } from "./shared.js";
|
|
|
|
const arrayFindLast =
|
|
Array.prototype.findLast ??
|
|
function (callback) {
|
|
for (let index = this.length - 1; index >= 0; index--) {
|
|
const element = this[index];
|
|
if (callback(element, index, this)) {
|
|
return element;
|
|
}
|
|
}
|
|
};
|
|
|
|
const findLast = /* @__PURE__ */ createMethodShim("findLast", function () {
|
|
if (Array.isArray(this)) {
|
|
return arrayFindLast;
|
|
}
|
|
});
|
|
|
|
export default findLast;
|