Improved Promise polyfill for MicroPython only (#1517)

This commit is contained in:
Andrea Giammarchi
2023-06-09 12:53:31 +02:00
committed by GitHub
parent 50b1a1d7c5
commit 818614b798
4 changed files with 10 additions and 44 deletions

View File

@@ -1,21 +1,7 @@
import { getBuffer } from "../fetch-utils.js";
import { absoluteURL, defineProperty } from "../utils.js";
import "@ungap/with-resolvers";
// REQUIRES INTEGRATION TEST
/* c8 ignore start */
// TODO: this should *NOT* be needed as the polyfill
// already patches on demand the Promise object
const { withResolvers } = Promise;
defineProperty(globalThis, "Promise", {
configurable: true,
value: class extends Promise {
withResolvers() {
return withResolvers.call(this);
}
},
});
/* c8 ignore stop */
import { getBuffer } from "../fetch-utils.js";
import { absoluteURL } from "../utils.js";
/**
* Trim code only if it's a single line that prettier or other tools might have modified.