new polyfill

This commit is contained in:
MathMan05
2026-06-26 22:26:09 -05:00
parent 9bdead02d1
commit 1f8d5a3023
+12
View File
@@ -48,6 +48,18 @@ function defineItter(itter: typeof Iterator) {
i++;
}
};
itter.prototype.find ??= function find<U>(
callbackfn: (element: U, index: number) => boolean,
): U | undefined {
let i = 0;
for (const thing of this) {
if (callbackfn(thing, i)) {
return thing;
}
i++;
}
return undefined;
};
}
if ("Iterator" in globalThis) {
defineItter(globalThis.Iterator);