Add basic Array.from polyfill for IE11

This commit is contained in:
Nick O'Leary 2020-05-21 10:26:24 +01:00
parent 57f0fbbb98
commit 5dc1cc54d5
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
1 changed files with 8 additions and 3 deletions

View File

@ -18,17 +18,22 @@
// changes to support iterables.
throw new Error("Missing Array.from base polyfill");
}
Array._from = Array.from;
Array.from = function() {
if (arguments.length > 1) {
throw new Error("Node-RED's IE11 Array.from polyfill doesn't support multiple arguments");
}
var arrayLike = arguments[0]
if (arrayLike.forEach) {
var result = [];
arrayLike.forEach(function(i) {
result.push(i);
})
return result;
} else {
for (var i=0;i<arrayLike.length;i++) {
result.push(arrayList[i]);
}
}
return Array._from.apply(null,arguments);
return result;
}
}
})();