Skip to content

Commit

Permalink
feat: Pre-convert the worker setup to a string
Browse files Browse the repository at this point in the history
  • Loading branch information
hughfenghen committed Mar 12, 2024
1 parent 40e2fd2 commit c4fa1d3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/access-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function getWorkerMsger() {
}

function create() {
const blob = new Blob([`(${opfsWorkerSetup.toString()})()`]);
const blob = new Blob([`(${opfsWorkerSetupStr})()`]);
const url = URL.createObjectURL(blob);
const worker = new Worker(url);

Expand Down Expand Up @@ -127,7 +127,7 @@ function getWorkerMsger() {
}
}

const opfsWorkerSetup = (): void => {
const opfsWorkerSetupStr = ((): void => {
const fileAccesserMap: Record<string, FileSystemSyncAccessHandle> = {};

self.onmessage = async (e) => {
Expand Down Expand Up @@ -183,4 +183,4 @@ const opfsWorkerSetup = (): void => {
});
}
};
};
}).toString();

0 comments on commit c4fa1d3

Please sign in to comment.