mirror of
https://github.com/codedread/bitjs
synced 2025-10-05 10:29:24 +02:00
For issue #44, make the Zipper use MessageChannel and not have a hard dependency on Worker
This commit is contained in:
parent
eeb228a52b
commit
48766d0136
5 changed files with 116 additions and 81 deletions
21
archive/webworker-wrapper.js
Normal file
21
archive/webworker-wrapper.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
/**
|
||||
* webworker-wrapper.js
|
||||
*
|
||||
* Licensed under the MIT License
|
||||
*
|
||||
* Copyright(c) 2023 Google Inc.
|
||||
*/
|
||||
|
||||
/**
|
||||
* A WebWorker wrapper for a decompress/compress implementation. Upon creation and being sent its
|
||||
* first message, it dynamically imports the decompressor / compressor implementation and connects
|
||||
* the message port. All other communication takes place over the MessageChannel.
|
||||
*/
|
||||
|
||||
/** @type {MessagePort} */
|
||||
let implPort;
|
||||
|
||||
onmessage = async (evt) => {
|
||||
const module = await import(evt.data.implSrc);
|
||||
module.connect(evt.ports[0]);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue