q
This commit is contained in:
parent
810ad6f5cb
commit
de7c6c32bd
123 changed files with 13201 additions and 6213 deletions
15
tests/helpers-generation-worker-node-wrapper.mjs
Normal file
15
tests/helpers-generation-worker-node-wrapper.mjs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import { parentPort } from 'node:worker_threads';
|
||||
|
||||
if (!parentPort) throw new Error('generation worker node wrapper requires parentPort');
|
||||
const pending = [];
|
||||
globalThis.self = {
|
||||
postMessage(data, transfer = []) {
|
||||
parentPort.postMessage(data, transfer);
|
||||
},
|
||||
};
|
||||
parentPort.on('message', (data) => {
|
||||
if (typeof globalThis.self.onmessage === 'function') globalThis.self.onmessage({ data });
|
||||
else pending.push(data);
|
||||
});
|
||||
await import('../src/generationWorker.js');
|
||||
while (pending.length) globalThis.self.onmessage({ data: pending.shift() });
|
||||
Loading…
Add table
Add a link
Reference in a new issue