Comparing version 0.1.0 to 0.1.1
{ | ||
"name": "accordant", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"keywords": [ | ||
@@ -14,2 +14,3 @@ "Worker", | ||
"./shared-worker": "./src/shared.js", | ||
"./transferable": "./src/transferable.js", | ||
"./worker": "./src/worker.js", | ||
@@ -16,0 +17,0 @@ "./package.json": "./package.json" |
import { isArray, stop } from './utils.js'; | ||
import Transferable from './transferable.js'; | ||
@@ -17,6 +18,13 @@ class EventHandler { | ||
const response = [channel, id]; | ||
const send = [response]; | ||
const proxy = await this.#promise; | ||
if (name in proxy) { | ||
try { | ||
response.push(await proxy[name](...args)); | ||
const result = await proxy[name](...args); | ||
if (result instanceof Transferable) { | ||
response.push(result.data); | ||
send.push(result.options); | ||
} | ||
else | ||
response.push(result); | ||
} | ||
@@ -30,3 +38,3 @@ catch (error) { | ||
} | ||
currentTarget.postMessage(response); | ||
currentTarget.postMessage(...send); | ||
} | ||
@@ -33,0 +41,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { withResolvers } from './utils.js'; | ||
import { assign, withResolvers } from './utils.js'; | ||
import accordant from './accordant.js'; | ||
@@ -6,2 +6,4 @@ | ||
const ffi = {}; | ||
addEventListener('connect', async ({ ports }) => { | ||
@@ -14,2 +16,2 @@ for (const port of ports) { | ||
export default resolve; | ||
export default bindings => resolve(assign(ffi, bindings)); |
const { isArray } = Array; | ||
export { isArray }; | ||
const { assign } = Object; | ||
export { assign, isArray }; | ||
@@ -4,0 +5,0 @@ export const stop = event => { |
@@ -1,2 +0,2 @@ | ||
import { withResolvers } from './utils.js'; | ||
import { assign, withResolvers } from './utils.js'; | ||
import accordant from './accordant.js'; | ||
@@ -6,4 +6,6 @@ | ||
const ffi = {}; | ||
accordant(self, promise); | ||
export default resolve; | ||
export default bindings => resolve(assign(ffi, bindings)); |
import exports from '../src/worker.js'; | ||
exports({ | ||
multiple: 'bindings', | ||
}); | ||
exports({ | ||
random: () => ({ Worker: Math.random() }), | ||
}); |
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
6488
11
143