mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-19 18:27:29 -05:00
25 lines
704 B
JavaScript
25 lines
704 B
JavaScript
// REQUIRES INTEGRATION TEST
|
|
/* c8 ignore start */
|
|
const workerHooks = [
|
|
["beforeRun", "codeBeforeRunWorker"],
|
|
["beforeRunAsync", "codeBeforeRunWorkerAsync"],
|
|
["afterRun", "codeAfterRunWorker"],
|
|
["afterRunAsync", "codeAfterRunWorkerAsync"],
|
|
];
|
|
|
|
export class Hook {
|
|
constructor(interpreter, options) {
|
|
this.interpreter = interpreter;
|
|
this.onWorkerReady = options.onWorkerReady;
|
|
for (const [key, value] of workerHooks) this[key] = options[value]?.();
|
|
}
|
|
get stringHooks() {
|
|
const hooks = {};
|
|
for (const [key] of workerHooks) {
|
|
if (this[key]) hooks[key] = this[key];
|
|
}
|
|
return hooks;
|
|
}
|
|
}
|
|
/* c8 ignore stop */
|