Packages

A web application in pursuit of meaning in life.

Retired package: Complete rewrite, scratch old versions

Current section

Files

Jump to
udia assets node_modules mout array findLastIndex.js
Raw

assets/node_modules/mout/array/findLastIndex.js

var makeIterator = require('../function/makeIterator_');
/**
* Returns the index of the last item that matches criteria
*/
function findLastIndex(arr, iterator, thisObj){
iterator = makeIterator(iterator, thisObj);
if (arr == null) {
return -1;
}
var n = arr.length;
while (--n >= 0) {
if (iterator(arr[n], n, arr)) {
return n;
}
}
return -1;
}
module.exports = findLastIndex;