{"_id":"@besync/comlink-ipc","_rev":"4-5d9f516d0fc1e420ff35c4e24ffb3721","name":"@besync/comlink-ipc","dist-tags":{"latest":"1.0.4"},"versions":{"1.0.2":{"name":"@besync/comlink-ipc","version":"1.0.2","description":"Besync's comlink-ipc makes WebWorkers, Sockets, named pipes and other IPC enjoyable","main":"dist/cjs/comlink.js","ts:main":"src/comlink.ts","types":"src/comlink.ts","scripts":{"build":"rm -rf dist && tsc"},"repository":{"type":"git","url":"git+https://github.com/besync/comlink.git"},"license":"Apache-2.0","devDependencies":{"typescript":"3.5.3"},"gitHead":"c2266853e153e91f8ece383521853543bce4d623","bugs":{"url":"https://github.com/besync/comlink/issues"},"homepage":"https://github.com/besync/comlink#readme","_id":"@besync/comlink-ipc@1.0.2","_nodeVersion":"10.16.3","_npmVersion":"6.9.0","dist":{"integrity":"sha512-/pLYRXDwQgItjZzfbT9BnDvh3h2JrRcgs9XPKtCqj0j34dbZz1BTbVpRHe/GwuYrcsxWTVuJG89JwuUP8oqueg==","shasum":"d894811f9fe53b4f3ac47df4de570e865661687a","tarball":"https://registry.npmjs.org/@besync/comlink-ipc/-/comlink-ipc-1.0.2.tgz","fileCount":18,"unpackedSize":59012,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdaB1/CRA9TVsSAnZWagAAJ9oP+wculqMcpEOR/2CEN4s0\n/9AClz6GHXVWoR7otq9OfEkmPaiMmd6/ujjXhvlYrMjgktCVa48CImOyN7nh\nZgIjD5XswnXGiosEQdXKUBJQ+fNapMkFJ5HWwwwM2ebwjlxS8ojggq9JaR7T\nN2oZFtH6WNsMVW+GN6XPtGvXoBIOhDjyFwdBP/wnlvkXulIj5OFy3LHn/6xj\nz2KfjpjbsJeseU0HgVhjThYJvgQBHfV4IWlm9b1FJ3T5yNC/FW8DMOdahbSL\nmR12pUodfO7zKwmSiQUsghbHYkFP7+yVdF3psaa/SiJ2iqOjFYXie+1MTIMc\neuTkOVgblQuqFrx68W0a4TizcoHGgwH5PRF4I39SnLPZ73hMhr1o9JcLNVq7\n/PiGl4ml6LomgsFIbT9p4gpHtA+3Uo3BuwSnMQKLpjM1TDn/+jWaZ5E8f0Vh\nq8jRA5OLY9jkabMKkQzaIlr1kGiibwTGEFMgleiWn8tlj4WynvxSJZEB0cLS\nNbRhteOunEraKoC8Fhn891RmltbLWP4KuXuImn8Vh7SAkME+IdbCa0E0EXF9\nL2TZ7yN6u+4m6tZjXOr3hoMsbOxz5iuYVLEVIwjurMBAKTwGDRDQZVS9i+pk\n5fmpOLdbBIyCp2ascyoDeDtNQGoAYudtuzfc+Q2KGtNG9VF6SWvOiJFU28yv\nG3UV\r\n=yZII\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFemOhPXeDGjzoHkWhtD4N16LByNugDGjWbUVT4nM0wMAiEAzfsZk+Pli5EHbXjzuT7BQ/OnRlXpu4QvM8wUoK+kOrw="}]},"maintainers":[{"name":"guycreate","email":"guy@nodekit.io"}],"_npmUser":{"name":"guycreate","email":"guy@nodekit.io"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/comlink-ipc_1.0.2_1567104382312_0.5310041900561988"},"_hasShrinkwrap":false},"1.0.3":{"name":"@besync/comlink-ipc","version":"1.0.3","description":"Besync's comlink-ipc makes WebWorkers, Sockets, named pipes and other IPC enjoyable","main":"dist/cjs/comlink.js","ts:main":"src/comlink.ts","types":"src/comlink.ts","scripts":{"build":"rm -rf dist && tsc"},"repository":{"type":"git","url":"git+https://github.com/besync/comlink.git"},"license":"Apache-2.0","devDependencies":{"typescript":"3.5.3"},"gitHead":"397a797236ba24962f799c481ca18e92b1b23d37","bugs":{"url":"https://github.com/besync/comlink/issues"},"homepage":"https://github.com/besync/comlink#readme","_id":"@besync/comlink-ipc@1.0.3","_nodeVersion":"10.16.3","_npmVersion":"lerna/3.16.4/node@v10.16.3+x64 (darwin)","dist":{"integrity":"sha512-vu+/QqT86wbf4LWixo9WSeHYD+7UhuzGQ4mmeXOEdjADDvqfl7YMX4F9yAt6ZVGM50HQEAWPPsi73jwOF+FpQA==","shasum":"78ea28c007f6b2b4255b128ecd387242ab9a01bc","tarball":"https://registry.npmjs.org/@besync/comlink-ipc/-/comlink-ipc-1.0.3.tgz","fileCount":17,"unpackedSize":52864,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdaC6hCRA9TVsSAnZWagAALiEP/1tGcQNwEP/HnldTVFSb\nioy0rbHccBdQt3JzERHxU7EUUd6mZ/qUdAA66QoR6GJ43F/Q3RIgMrGz4bEs\nRlAG+rmqp0PK2sdL8yktj/1DgxVpg+ZNBOio8jEVVs6mNjcxH2syVKvHetlH\nwA7VMk1ST3VSet5L3ubCBKLEfhIlXEiCry+sYKlHc+8B2330Ci/hglZ/izwi\nS7VQSF7EEky7EzRohRsbymtuFPFYXkOLwaGysEUKi1eqU0ngyCoFl1PRza6z\nu6SQt0o1+oZdqgYAYFzRD5MKEBsbCOjrAreSKav80js2yuwmbbI8cTNDl9qU\nibfrSRLTDFmre7KhhMMc+/1rf0woqm8LQUXvwbPXHJvtRchY7N/Yw3bEaBRN\nceVPN7J7Fmij2IIsGk9qP9+CrfvvmfTnQuqizRaNPm6f9vcG3F6XsX3Iq8sR\ntW52+5jtu1jXd/r7oztsKhnSUiX5pJzLViypW36Y8KFqr2dal0NvAnrQZd5E\n2nJXD3kPLLegyJ1vF6ta9n08Ra0t5xhgXP2BrkHTehxlXe2ZAAjALDQsgwDX\nbGPfBGUtUEvb8865cK0/s8DNNeTCLmPF1WlVhAae/S/CkdtQdOBIp1YDeBZw\nMz3k5NuZHlcBTk3a0EoUx0nsiUSFrN5waGiJxJowbqvV4hPCNjmd2n2ZikSS\n5GIS\r\n=KN2Y\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDvvCkPr3d7gcahZ7Wb/PaHJqplSlii6STSZje3dVja5AIhAOczjDNBgmY9WlPa00mAUaQiDkmCOZf44fnE7zTexmvH"}]},"maintainers":[{"name":"guycreate","email":"guy@nodekit.io"}],"_npmUser":{"name":"guycreate","email":"guy@nodekit.io"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/comlink-ipc_1.0.3_1567108768517_0.9416112942802066"},"_hasShrinkwrap":false},"1.0.4":{"name":"@besync/comlink-ipc","version":"1.0.4","description":"Besync's comlink-ipc makes WebWorkers, Sockets, named pipes and other IPC enjoyable","main":"dist/cjs/comlink.js","ts:main":"src/comlink.ts","types":"src/comlink.ts","scripts":{"build":"rm -rf dist && tsc"},"repository":{"type":"git","url":"git+https://github.com/besync/comlink.git"},"license":"Apache-2.0","devDependencies":{"typescript":"3.5.3"},"gitHead":"cbef6fa8b12679a0779bac99fbb71ef464ba359d","bugs":{"url":"https://github.com/besync/comlink/issues"},"homepage":"https://github.com/besync/comlink#readme","_id":"@besync/comlink-ipc@1.0.4","_nodeVersion":"10.16.3","_npmVersion":"lerna/3.16.4/node@v10.16.3+x64 (darwin)","dist":{"integrity":"sha512-fVIag+DpWghzzy74OecC2orZNjNUXm8rPvj5eBrKnGe+9/Vcek+KmIknbCTUYwHfzx+BQznouthDrvz8w2/E0g==","shasum":"483a2b0d7d6bb36e8d79a43ce2a475c2d2159f65","tarball":"https://registry.npmjs.org/@besync/comlink-ipc/-/comlink-ipc-1.0.4.tgz","fileCount":17,"unpackedSize":52817,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdanDNCRA9TVsSAnZWagAAY4wP/2PmXQT1I3oDZuurwpva\nEAg6oyflLKRNUA9wMau7HdxtQEoLN3QKiIaReU0V6261NTaI+FgijjMATMf8\nzdaLWLm9HgB4hG5TenkGkUmFtLKbd1pmEV3fAhtWXL3zd3JRl9oezkKUe0Av\nrw05BdxdvRWgIEYZudD2Z43FezNZWMsamhS73X5zVoYKDOu+I6LpNMhTW/T+\ncGKiK+EbqJVufLtJkbIxCtlmQOBRUxTb5mtQ1WddvTsOSBPZKBH7ngjYSuNO\naGiZHFqNKwEdsY3KzXWjwVcn5En2TL/wrfJNZ4ooOeYRauRRxbzTqadDgTnF\nOlewsgttE2mnVzM/cbYsOEv3UTgrtj9nZ43GCc/uKjDwQfS3XvhHS5AWmLul\nIHrekTSjR+K57ZFg76y5yZn/6QM2D4m0W3bJbNIS0Dxg2iNi5fq8ETW0dD1t\n6VLI85kK4D4lwUmxPK4u5nhsd9lcToWF8DuzNUSHu62W4XC4MGuweAfuZKk6\n087+lGIOhQyHUsnNit3cBl0ML6LEiXC+ivOs9sZKj/kotjH2Z0VxNkVxYmKy\nFb4i4ulnc35oElScBf4I1hklGzl9dy1X/ZJ0ylGxCQKg9G7vz6t+Ti66u8OK\nfwQ9L4lonQf9i/9c56DaUddg64/g8Q3G5EENLhWMHGg6f/4WkDaOEq6HHwlZ\n/o31\r\n=sP/f\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDC/3HTErmnKP50Zm4QoJe7Y83H9vp38NvgZjp+Lh6lIgIgHOVW9y5mLMVKwnnEkLnBsaQUC1h2QsiHooRXSgEyOyU="}]},"maintainers":[{"name":"guycreate","email":"guy@nodekit.io"}],"_npmUser":{"name":"guycreate","email":"guy@nodekit.io"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/comlink-ipc_1.0.4_1567256781321_0.7443300292039907"},"_hasShrinkwrap":false}},"time":{"created":"2019-08-29T18:46:22.254Z","1.0.2":"2019-08-29T18:46:22.559Z","modified":"2022-04-04T18:33:57.118Z","1.0.3":"2019-08-29T19:59:28.623Z","1.0.4":"2019-08-31T13:06:21.434Z"},"maintainers":[{"email":"admin@tinia.org","name":"tinialabs1"},{"email":"guy-nodekit@barnardmail.net","name":"guycreate"}],"description":"Besync's comlink-ipc makes WebWorkers, Sockets, named pipes and other IPC enjoyable","homepage":"https://github.com/besync/comlink#readme","repository":{"type":"git","url":"git+https://github.com/besync/comlink.git"},"bugs":{"url":"https://github.com/besync/comlink/issues"},"license":"Apache-2.0","readme":"# comlink-ipc\n\n## Fork\nForked from GoogleChromeLabs/comlink to remove dependency on browser webworkers and MessageChannel and use more generically indepdent of transport.\n\n## API\n\n### `Comlink.wrap(endpoint)` and `Comlink.expose(value, endpoint?)`\n\nComlink’s goal is to make _exposed_ values from one thread available in the other. `expose` exposes `value` on `endpoint`, where `endpoint` is a [`postMessage`-like interface][endpoint].\n\n`wrap` wraps the _other_ end of the message channel and returns a proxy. The proxy will have all properties and functions of the exposed value, but access and invocations are inherently asynchronous. This means that a function that returns a number will now return _a promise_ for a number. **As a rule of thumb: If you are using the proxy, put `await` in front of it.** Exceptions will be caught and re-thrown on the other side.\n\nLastly, you can use `Comlink.proxy(value)`. When using this Comlink will not copy the value, but instead send a proxy. Both threads now work on the same value. This is useful for callbacks, for example, as functions are not structured cloneable.\n\n```js\nmyProxy.onready = Comlink.proxy(data => {\n  /* ... */\n});\n```\n\n### Transfer handlers and event listeners\n\nIt is common that you want to use Comlink to add an event listener, where the event source is on another thread:\n\n```js\nbutton.addEventListener(\"click\", myProxy.onClick.bind(myProxy));\n```\n\nWhile this won’t throw immediately, `onClick` will never actually be called. This is because [`Event`][event] is neither structured cloneable nor transferable. As a workaround, Comlink offers transfer handlers.\n\nEach function parameter and return value is given to _all_ registered transfer handlers. If one of the event handler signals that it can process the value by returning `true` from `canHandle()`, it is now responsible for serializing the value to structured cloneable data and for deserializing the value. A transfer handler has be set up on _both sides_ of the message channel. Here’s an example transfer handler for events:\n\n```js\nComlink.transferHandlers.set(\"EVENT\", {\n  canHandle: obj => obj instanceof Event,\n  serialize: ev => {\n    return [{\n      target: {\n        id: ev.target.id\n        classList: [...ev.target.classList]\n      }\n    }, []];\n  },\n  deserialize: obj => obj,\n});\n```\n\nNote that this particular transfer handler won’t create an actual `Event`, but just an object that has the `event.target.id` and `event.target.classList` property. Often, this enough. If not, the transfer handler can be easily augmented to provide all necessary data.\n\n---\n\nLicense Apache-2.0\n","readmeFilename":"README.md"}