From edb092dff95abc73e721c7c4ad9e28a7752dc4db Mon Sep 17 00:00:00 2001 From: Emupedia Date: Wed, 27 Apr 2022 04:20:34 +0300 Subject: [PATCH] More work --- beta/emuos/assets/js/polyfills.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/beta/emuos/assets/js/polyfills.js b/beta/emuos/assets/js/polyfills.js index 30b13ff0..44c27336 100644 --- a/beta/emuos/assets/js/polyfills.js +++ b/beta/emuos/assets/js/polyfills.js @@ -392,6 +392,30 @@ if (typeof Array.isArray === 'undefined') { } } +if (!Array.prototype.find) { + console.log('Array.find polyfill loaded!'); + Array.prototype.find = function (callback) { + if (this === null) { + throw new TypeError('Array.prototype.find called on null or undefined'); + } else if (typeof callback !== 'function') { + throw new TypeError('callback must be a function'); + } + + var list = Object(this); + // Makes sures is always has an positive integer as length. + var length = list.length >>> 0; + var thisArg = arguments[1]; + + for (var i = 0; i < length; i++) { + var element = list[i]; + + if (callback.call(thisArg, element, i, list)) { + return element; + } + } + }; +} + // IE 11.592.18362.0 if (!Array.from) { console.log('Array.from polyfill loaded!');