Spaces:
Running
Running
File size: 1,033 Bytes
f2bee8a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
/* eslint-disable no-extend-native */
if (!Blob.prototype.text) {
Blob.prototype.text = function () {
return new Promise((resolve, reject) => {
const fr = new FileReader();
fr.onload = () => resolve(fr.result);
fr.onerror = () => reject(new Error('Cannot read blob as text'));
fr.readAsText(this);
});
};
}
if (!Array.prototype.flat) {
Array.prototype.flat = function (depth = 1) {
const result = [];
for (const i of this) {
if (Array.isArray(i)) {
if (depth < 1) {
result.push(i);
} else {
for (const j of i.flat(depth - 1)) {
result.push(j);
}
}
} else {
result.push(i);
}
}
return result;
};
}
if (typeof queueMicrotask !== 'function') {
window.queueMicrotask = callback => {
Promise.resolve().then(callback);
};
}
|