workerboxjs
Advanced tools
Comparing version 5.2.0 to 5.3.0
@@ -43,3 +43,3 @@ import createCallbackStore from './createCallbackStore.js'; | ||
if (options.appendVersion) { | ||
scriptUrl = scriptUrl + '/v5.2.0/'; | ||
scriptUrl = scriptUrl + '/v5.3.0/'; | ||
} | ||
@@ -62,8 +62,10 @@ | ||
const run = (id, args) => | ||
new Promise(resolve => { | ||
instance.postMessage(['callback', { id, args, resolve: callbacks.add(resolve) }]); | ||
new Promise((resolve, reject) => { | ||
instance.postMessage(['callback', { | ||
id, args, resolve: callbacks.add(resolve), reject: callbacks.add(reject) | ||
}]); | ||
}); | ||
const instance = await createWorkerboxInstance(scriptUrl.href, async message => { | ||
const [action, { id, args, resolve }] = message.data; | ||
const [action, { id, args, resolve, reject }] = message.data; | ||
@@ -87,4 +89,8 @@ const parsedArgs = stringToArgs(args, callbacks.add, run); | ||
const result = await fn(...parsedArgs); | ||
instance.postMessage(['callback', { id: resolve, args: argsToString([result], callbacks.add, run) }]); | ||
try { | ||
const result = await fn(...parsedArgs); | ||
instance.postMessage(['callback', { id: resolve, args: argsToString([result], callbacks.add, run) }]); | ||
} catch (error) { | ||
instance.postMessage(['callback', { id: reject, args: argsToString([error.message], callbacks.add, run) }]); | ||
} | ||
}); | ||
@@ -91,0 +97,0 @@ |
{ | ||
"name": "workerboxjs", | ||
"version": "5.2.0", | ||
"version": "5.3.0", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "description": "A secure sandbox to execute untrusted user JavaScript, in a web browser, without any risk to your own domain/site/page.", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11753
185