{"versions":{"1.2.0":{"name":"@eshaz/web-worker","version":"1.2.0","description":"Consistent Web Workers in browser and Node.","main":"./cjs/node.js","browser":"./cjs/browser.js","types":"index.d.ts","scripts":{"prepare":"babel node.js browser.js -d cjs","test":"eslint '*.js' test && node --experimental-modules ./node_modules/.bin/ava"},"babel":{"plugins":["@babel/plugin-syntax-dynamic-import","babel-plugin-commonjs-lite"]},"repository":{"type":"git","url":"git+https://github.com/eshaz/web-worker.git"},"keywords":["worker","worker_threads","webworker","web worker","web-worker","threads"],"authors":[],"license":"Apache-2.0","homepage":"https://github.com/eshaz/web-worker","eslintConfig":{"extends":"developit","rules":{"no-console":0}},"devDependencies":{"@babel/cli":"^7.7.7","@babel/core":"^7.7.7","@babel/plugin-syntax-dynamic-import":"^7.7.4","@babel/plugin-transform-modules-commonjs":"^7.7.5","@babel/preset-env":"^7.7.7","ava":"^2.4.0","babel-plugin-commonjs-lite":"gist:3e38560d5bed35da1fd708d635e4acb3","eslint":"^6.8.0","eslint-config-developit":"^1.1.1"},"gitHead":"61b31eb1c1b981282b32bcf6606705ad63309a2f","bugs":{"url":"https://github.com/eshaz/web-worker/issues"},"_id":"@eshaz/web-worker@1.2.0","_nodeVersion":"18.12.1","_npmVersion":"8.19.2","dist":{"integrity":"sha512-HWobmNKFZ8eARo39vEjkviTIISudgzrTyAqab9pOB/qNfnUPIUUMZv6+eEUUfXnkqWCLS3zreTn9YzaRvO8vIA==","shasum":"a71c47e63c3325c227c619c217e3982578bde951","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/@eshaz/web-worker/-/web-worker-1.2.0.tgz","fileCount":8,"unpackedSize":30601,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBawhG0K08WQ70ZM+nLJwlUNZUrSow50gXmWQCqqmpLOAiAnTaGUR7q2cL6BiLywpJfRv/XMVFsujm24TcXLrbarhQ=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjlknzACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmpHIw/+PH+ywNmZufIqlE/mgIaGAAH0aM35lbFT+ehVpHk8mVt5zUWg\r\nA796HC1+lH3yvFpX8UlO2aES34ffApJoFcl7gocnhiZKDl0f3JEJQrrHsnqL\r\ngNqTAPGVMS3VgL1Z8tQav3g2JuAYkqXamHDBwdy8bArAna/UbQUroq/W9Y3u\r\nk+G2hFA1AsnCA44v4TeNbO1j7YelTLzxmGmkAGp8r3/UhNYYbCbcsZWSDXf+\r\nX1md+06H3x9eKzVVpNuZ+GSA7vttTGvNVgzRTOgYoDbGHrvtSSCUrpdWnOiB\r\ngV5ItIs1sh3H9y9crf+BqPoA3fKABUX6L5vfbmI2JAJdKlxAMmiZCCTLiYW4\r\noTLPSnrvxDSxQfhbZWH7z8oucQmCOoR+GgQho47KV9kONiG6cN/KCuzxRA5n\r\nIsXtI5WWY5DpC5bRsUtARiITY/MdDogyYuEBZNO/zgnjHcZGBX8TOSQSG7Up\r\nZVsPTE7VzedObV1euQn7bIrPx2S+nPBSBR8RcNeTNOq4oXYzZOOM1Ff0YNmf\r\nGch8cr6Qjgv2xAo6vggd69/KTwoG1nFoeuyjiKq6uTva9NoSYJ7Ze+YqFy9M\r\n49IFoYJgMtCPdl/Boe7HYXUJoUv+U97YS7/z8YgYdv12lL7eNQ0uWUeJohlX\r\ni86DpusXOUgjvlWursr5auzY66T4Zo/3eA4=\r\n=JsA5\r\n-----END PGP SIGNATURE-----\r\n","size":9151},"_npmUser":{"name":"anonymous","email":"ethanshalsall@gmail.com"},"directories":{},"maintainers":[{"name":"anonymous","email":"ethanshalsall@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/web-worker_1.2.0_1670793715701_0.12060995281034437"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-12-11T21:22:02.030Z","contributors":[]},"1.2.1":{"name":"@eshaz/web-worker","version":"1.2.1","description":"Consistent Web Workers in browser and Node.","main":"./cjs/node.js","browser":"./cjs/browser.js","types":"index.d.ts","scripts":{"prepare":"babel node.js browser.js -d cjs","test":"eslint '*.js' test && node --experimental-modules ./node_modules/.bin/ava"},"babel":{"plugins":["@babel/plugin-syntax-dynamic-import","babel-plugin-commonjs-lite"]},"repository":{"type":"git","url":"git+https://github.com/eshaz/web-worker.git"},"keywords":["worker","worker_threads","webworker","web worker","web-worker","threads"],"authors":[],"license":"Apache-2.0","homepage":"https://github.com/eshaz/web-worker","eslintConfig":{"extends":"developit","rules":{"no-console":0}},"devDependencies":{"@babel/cli":"^7.7.7","@babel/core":"^7.7.7","@babel/plugin-syntax-dynamic-import":"^7.7.4","@babel/plugin-transform-modules-commonjs":"^7.7.5","@babel/preset-env":"^7.7.7","ava":"^2.4.0","babel-plugin-commonjs-lite":"gist:3e38560d5bed35da1fd708d635e4acb3","eslint":"^6.8.0","eslint-config-developit":"^1.1.1","eslint-plugin-compat":"^4.1.4"},"gitHead":"5ec99ac04b1c12b4fcc4348be5623fc4ebd9f54c","bugs":{"url":"https://github.com/eshaz/web-worker/issues"},"_id":"@eshaz/web-worker@1.2.1","_nodeVersion":"18.16.0","_npmVersion":"9.5.1","dist":{"integrity":"sha512-v5AKAVtM0toVD2rDCGjzhySWlXG/sG5HVialdzrxFKTAnFZNCjQelX0n2tPK0tE86jf4s3hpWlpRtOh8OObktg==","shasum":"834385830529582589e9790350beb24bf3ac8018","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/@eshaz/web-worker/-/web-worker-1.2.1.tgz","fileCount":8,"unpackedSize":30704,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCQIdBaUb4BD503KFephD0lTZ0liIDWuL+qD4qIvHyxUQIgfxYMX0GAfg5MQ9keaKKUN6k2BYP+h2dHAM/NCZTHiP8="}],"size":9170},"_npmUser":{"name":"anonymous","email":"ethanshalsall@gmail.com"},"directories":{},"maintainers":[{"name":"anonymous","email":"ethanshalsall@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/web-worker_1.2.1_1685673197278_0.9621531422277432"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-06-02T02:33:17.456Z","publish_time":1685673197456,"_source_registry_name":"default","contributors":[]},"1.2.2":{"name":"@eshaz/web-worker","version":"1.2.2","description":"Consistent Web Workers in browser and Node.","main":"./cjs/node.js","browser":"./cjs/browser.js","types":"index.d.ts","scripts":{"prepare":"babel node.js browser.js -d cjs","test":"eslint '*.js' test && node --experimental-modules ./node_modules/.bin/ava"},"babel":{"plugins":["@babel/plugin-syntax-dynamic-import","babel-plugin-commonjs-lite"]},"repository":{"type":"git","url":"git+https://github.com/eshaz/web-worker.git"},"keywords":["worker","worker_threads","webworker","web worker","web-worker","threads"],"authors":[],"license":"Apache-2.0","homepage":"https://github.com/eshaz/web-worker","eslintConfig":{"extends":"developit","rules":{"no-console":0}},"devDependencies":{"@babel/cli":"^7.7.7","@babel/core":"^7.7.7","@babel/plugin-syntax-dynamic-import":"^7.7.4","@babel/plugin-transform-modules-commonjs":"^7.7.5","@babel/preset-env":"^7.7.7","ava":"^2.4.0","babel-plugin-commonjs-lite":"gist:3e38560d5bed35da1fd708d635e4acb3","eslint":"^6.8.0","eslint-config-developit":"^1.1.1","eslint-plugin-compat":"^4.1.4"},"gitHead":"8d1e4bbf49f283fe59fdda20f633286148770696","bugs":{"url":"https://github.com/eshaz/web-worker/issues"},"_id":"@eshaz/web-worker@1.2.2","_nodeVersion":"18.17.1","_npmVersion":"9.6.7","dist":{"integrity":"sha512-WxXiHFmD9u/owrzempiDlBB1ZYqiLnm9s6aPc8AlFQalq2tKmqdmMr9GXOupDgzXtqnBipj8Un0gkIm7Sjf8mw==","shasum":"506ec07ab811c15a12799725a0d8b82289e3d937","tarball":"http://123.232.10.234:8212/nexus/content/groups/npm-public/@eshaz/web-worker/-/web-worker-1.2.2.tgz","fileCount":8,"unpackedSize":30716,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAvA4EIxg9JM0Av9aGr9YbRFApwTWTvupqyYdEtW9PQwAiEAiM+9abHGCWuUzGSvz1G/kCdZNsBq5cnxxaYU577ptSw="}],"size":9172},"_npmUser":{"name":"anonymous","email":"ethanshalsall@gmail.com"},"directories":{},"maintainers":[{"name":"anonymous","email":"ethanshalsall@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/web-worker_1.2.2_1701017600992_0.1000840114228172"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-11-26T16:53:21.189Z","publish_time":1701017601189,"_source_registry_name":"default","contributors":[]}},"dist-tags":{"latest":"1.2.2"},"name":"@eshaz/web-worker","time":{"created":"2022-12-11T21:22:03.895Z","modified":"2023-11-26T17:11:13.045Z","1.2.0":"2022-12-11T21:21:55.853Z","1.2.1":"2023-06-02T02:33:17.456Z","1.2.2":"2023-11-26T16:53:21.189Z"},"readme":"<h1 align=\"center\">\n  web-worker\n  <a href=\"https://www.npmjs.org/package/web-worker\"><img src=\"https://img.shields.io/npm/v/web-worker.svg?style=flat-square\" alt=\"npm\"></a>\n</h1>\n<p align=\"center\">\n  Native cross-platform Web Workers. Works in published npm modules.\n</p>\n<p align=\"center\">\n  <img src=\"https://user-images.githubusercontent.com/105127/79602228-1998bf00-80b8-11ea-91e4-26b212aabaa2.png\" width=\"1000\" alt=\"\">\n</p>\n\n**In Node**, it's a web-compatible Worker implementation atop Node's [worker_threads](https://nodejs.org/api/worker_threads.html).\n\n**In the browser** (and when bundled for the browser), it's simply an alias of `Worker`.\n\n### Features\n\n_Here's how this is different from worker_threads:_\n\n- makes Worker code compatible across browser and Node\n- supports Module Workers (`{type:'module'}`) natively in Node 12.8+\n- uses DOM-style events (`Event.data`, `Event.type`, etc)\n- supports event handler properties (`worker.onmessage=..`)\n- `Worker()` accepts a module URL, Blob URL or Data URL\n- emulates browser-style [WorkerGlobalScope] within the worker\n\n### Usage Example\n\nIn its simplest form:\n\n```js\nimport Worker from 'web-worker';\n\nconst worker = new Worker('data:,postMessage(\"hello\")');\nworker.onmessage = e => console.log(e.data);  // \"hello\"\n```\n\n<table>\n<thead><tr><th><strong>main.js</strong></th><th><strong>worker.js</strong></th></tr></thead>\n<tbody><tr><td>\n\n```js\nimport Worker from 'web-worker';\n\nconst url = new URL('./worker.js', import.meta.url);\nconst worker = new Worker(url);\n\nworker.addEventListener('message', e => {\n  console.log(e.data)  // \"hiya!\"\n});\n\nworker.postMessage('hello');\n```\n\n</td><td valign=\"top\">\n\n```js\naddEventListener('message', e => {\n  if (e.data === 'hello') {\n    postMessage('hiya!');\n  }\n});\n```\n\n</td></tr></tbody>\n</table>\n\n👉 Notice how `new URL('./worker.js', import.meta.url)` is used above to load the worker relative to the current module instead of the application base URL. Without this, Worker URLs are relative to a document's URL, which in Node.js is interpreted to be `process.cwd()`.\n\n> _Support for this pattern in build tools and test frameworks is still limited. We are [working on growing this](https://github.com/developit/web-worker/issues/4)._\n\n### Module Workers\n\nModule Workers are supported in Node 12.8+ using this plugin, leveraging Node's native ES Modules support.\nIn the browser, they can be used natively in Chrome 80+, or in all browsers via [worker-plugin] or [rollup-plugin-off-main-thread]. As with classic workers, there is no difference in usage between Node and the browser:\n\n<table>\n<thead><tr><th><strong>main.mjs</strong></th><th><strong>worker.mjs</strong></th></tr></thead>\n<tbody><tr><td>\n\n```js\nimport Worker from 'web-worker';\n\nconst worker = new Worker(\n  new URL('./worker.mjs', import.meta.url),\n  { type: 'module' }\n);\nworker.addEventListener('message', e => {\n  console.log(e.data)  // \"200 OK\"\n});\nworker.postMessage('https://httpstat.us/200');\n```\n\n</td><td valign=\"top\">\n\n```js\nimport fetch from 'isomorphic-fetch';\n\naddEventListener('message', async e => {\n  const url = e.data;\n  const res = await fetch(url)\n  const text = await res.text();\n  postMessage(text);\n});\n```\n\n</td></tr></tbody>\n</table>\n\n\n### Data URLs\n\nInstantiating Worker using a Data URL is supported in both module and classic workers:\n\n```js\nimport Worker from 'web-worker';\n\nconst worker = new Worker(`data:application/javascript,postMessage(42)`);\nworker.addEventListener('message', e => {\n  console.log(e.data)  // 42\n});\n```\n\n### Special Thanks\n\nThis module aims to provide a simple and forgettable piece of infrastructure,\nand as such it needed an obvious and descriptive name.\n[@calvinmetcalf](https://github.com/calvinmetcalf), who you may recognize as the author of [Lie](https://github.com/calvinmetcalf/lie) and other fine modules, gratiously offered up the name from his `web-worker` package.\nThanks Calvin!\n\n\n[worker-plugin]: https://github.com/googlechromelabs/worker-plugin\n[rollup-plugin-off-main-thread]: https://github.com/surma/rollup-plugin-off-main-thread\n[WorkerGlobalScope]: https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope","users":{}}