eslint-config-chain-able
Version:
an opinionated ESLint configuration
23 lines (20 loc) • 522 B
JavaScript
var ES = require('es-abstract/es6');
module.exports = function find(predicate) {
var list = ES.ToObject(this);
var length = ES.ToInteger(ES.ToLength(list.length));
if (!ES.IsCallable(predicate)) {
throw new TypeError('Array#find: predicate must be a function');
}
if (length === 0) {
return undefined;
}
var thisArg = arguments[1];
for (var i = 0, value; i < length; i++) {
value = list[i];
if (ES.Call(predicate, thisArg, [value, i, list])) {
return value;
}
}
return undefined;
};
;