Skip to content

Commit 1eb56d1

Browse files
authored
tweaks.
1 parent b41cf39 commit 1eb56d1

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

greenlet.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default function greenlet(asyncFunction) {
1010
const promises = {};
1111

1212
// Use a data URI for the worker's src. It inlines the target function and an RPC handler:
13-
const script = 'data:$$='+asyncFunction+';onmessage='+(e => {
13+
const script = '$$='+asyncFunction+';onmessage='+(e => {
1414
/* global $$ */
1515

1616
// Invoking within then() captures exceptions in the supplied async function as rejections
@@ -30,8 +30,7 @@ export default function greenlet(asyncFunction) {
3030
er => { postMessage([e.data[0], 1, '' + er]); }
3131
);
3232
});
33-
const blob = new Blob([script]);
34-
const workerURL = URL.createObjectURL(blob);
33+
const workerURL = URL.createObjectURL(new Blob([script]));
3534
// Create an "inline" worker (1:1 at definition time)
3635
const worker = new Worker(workerURL);
3736

@@ -61,7 +60,7 @@ export default function greenlet(asyncFunction) {
6160
worker.postMessage([currentId, args], args.filter(x => (
6261
(x instanceof ArrayBuffer) ||
6362
(x instanceof MessagePort) ||
64-
(window.createImageBitmap && x instanceof ImageBitmap)
63+
(self.ImageBitmap && x instanceof ImageBitmap)
6564
)));
6665
});
6766
};

0 commit comments

Comments
 (0)