UNPKG

array-find-es6

Version:

ES6 Array.find ponyfill. Return the first array element which satisfies a testing function.

2 lines (1 loc) 242 B
module.exports=function(n,r,t){if("function"==typeof Array.prototype.find)return n.find(r,t);t=t||this;var o=n.length;if("function"!=typeof r)throw new TypeError(r+" is not a function");for(var f=0;f<o;f++)if(r.call(t,n[f],f,n))return n[f]};