export function arrayPrototypeFind( this: E, a: T[], predicate: FindPredicate, thisArg?: E ): T | undefined { for (let i = 0; i < a.length; i++) { const v = a[i] if (predicate.apply(thisArg, [v, i, a])) { return v } } } export type FindPredicate = (this: E, value: T, index: number, obj: T[]) => boolean export function installArrayPrototypeFind(force = false) { Array.prototype.find = typeof Array.prototype.find === 'undefined' || force ? function (this: Array, predicate: FindPredicate, thisArg?: any): T | undefined { //@ts- ignore return arrayPrototypeFind(this, predicate, thisArg) } : Array.prototype.find }