Worker sync utility (#1511)

* patched an issue with wasmoon randomly asking to resolve proxy references
  * simplified pyodide and micropython dance by grouping their common utilities together
  * created an integration test around a worker to main thread input between MicroPython and Lua
  * commented some weird bugs / funny behaviors around both MicroPython and Pyodide
  * other minor clean ups
This commit is contained in:
Andrea Giammarchi
2023-06-08 11:10:47 +02:00
committed by GitHub
parent 0cdbfbeb30
commit af72e232c3
26 changed files with 277 additions and 81 deletions

View File

@@ -1,10 +1,26 @@
import { getBuffer } from "../fetch-utils.js";
import { absoluteURL } from "../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 */
/**
* Trim code only if it's a single line that prettier or other tools might have modified.
* @param {string} code code that might be a single line
* @returns {strong}
* @returns {string}
*/
export const clean = (code) =>
code.replace(/^[^\r\n]+$/, (line) => line.trim());