{"name":"webworkify","version":"1.5.0","description":"launch a web worker that can require() in the browser with browserify","main":"index.js","dependencies":{},"devDependencies":{"gamma":"~0.1.0","tape":"~1.0.4"},"scripts":{"test":"tape test/*.js"},"repository":{"type":"git","url":"git://github.com/substack/webworkify.git"},"homepage":"https://github.com/substack/webworkify","keywords":["web","worker","background","browser","fork"],"author":{"name":"James Halliday","email":"mail@substack.net","url":"http://substack.net"},"license":"MIT","gitHead":"baf2884256768aea6c36be1ea6e1efb2144fcfbc","bugs":{"url":"https://github.com/substack/webworkify/issues"},"_id":"webworkify@1.5.0","_npmVersion":"5.5.1","_nodeVersion":"8.3.0","_npmUser":{"name":"anandthakker","email":"vestibule@anandthakker.net"},"dist":{"integrity":"sha512-AMcUeyXAhbACL8S2hqqdqOLqvJ8ylmIbNwUIqQujRSouf4+eUFaXbG6F1Rbu+srlJMmxQWsiU7mOJi0nMBfM1g==","shasum":"734ad87a774de6ebdd546e1d3e027da5b8f4a42c","tarball":"http://registry-npm.ywwl.com/webworkify/download/webworkify-1.5.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCIYk/rL7hZxL/js7bA6xcQNBPKMm7nRvcvTr7tgCrwtAIhAMiH/vP4t5OC6b5K0OUP+Ih+TgDXly64S6yVcCIPfLxI"}],"size":3617,"noattachment":false,"key":"/webworkify/-/webworkify-1.5.0.tgz"},"maintainers":[{"email":"agafonkin@gmail.com","name":"mourner"},{"email":"vestibule@anandthakker.net","name":"anandthakker"},{"email":"substack@gmail.com","name":"substack"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/webworkify-1.5.0.tgz_1510590639731_0.36480907746590674"},"directories":{},"readme":"# webworkify\n\nlaunch a web worker that can require() in the browser with browserify\n\n# example\n\nFirst, a `main.js` file will launch the `worker.js` and print its output:\n\n``` js\nvar work = require('webworkify');\n\nvar w = work(require('./worker.js'));\nw.addEventListener('message', function (ev) {\n    console.log(ev.data);\n});\n\nw.postMessage(4); // send the worker a message\n```\n\nthen `worker.js` can `require()` modules of its own. The worker function lives\ninside of the `module.exports`:\n\n``` js\nvar gamma = require('gamma');\n\nmodule.exports = function (self) {\n    self.addEventListener('message',function (ev){\n        var startNum = parseInt(ev.data); // ev.data=4 from main.js\n        \n        setInterval(function () {\n            var r = startNum / Math.random() - 1;\n            self.postMessage([ startNum, r, gamma(r) ]);\n        }, 500);\n    });\n};\n```\n\nNow after [browserifying](http://browserify.org) this example, the console will\ncontain output from the worker:\n\n```\n[ 4, 0.09162078520553618, 10.421030346237066 ]\n[ 4, 2.026562457360466, 1.011522336481017 ]\n[ 4, 3.1853125018703716, 2.3887589540750214 ]\n[ 4, 5.6989969260510005, 72.40768854476167 ]\n[ 4, 8.679491643020487, 20427.19357947782 ]\n[ 4, 0.8528139834191428, 1.1098187157762498 ]\n[ 4, 8.068322137547542, 5785.928308309402 ]\n...\n```\n\n# methods\n\n``` js\nvar work = require('webworkify')\n```\n\n## var w = work(require(modulePath))\n\nReturn a new\n[web worker](https://developer.mozilla.org/en-US/docs/Web/API/Worker)\nfrom the module at `modulePath`.\n\nThe file at `modulePath` should export its worker code in `module.exports` as a\nfunction that will be run with no arguments.\n\nNote that all the code outside of the `module.exports` function will be run in\nthe main thread too so don't put any computationally intensive code in that\npart. It is necessary for the main code to `require()` the worker code to fetch\nthe module reference and load `modulePath`'s dependency graph into the bundle\noutput.\n\n## Worker.objectURL\n\nThe worker `w` returned by `webworkify` has the property `objectURL` attached.\n`w.objectURL` refers to the Object URL that was used to pass the module's source\nto the worker, and can be cleaned up using `URL.revokeObjectURL()`.  (See [example](https://github.com/substack/webworkify/blob/master/example/main.js))\n\n# install\n\nWith [npm](https://npmjs.org) do:\n\n```\nnpm install webworkify\n```\n\n# license\n\nMIT\n","publish_time":1510590640657,"_cnpm_publish_time":1510590640657,"dist-tags":{"latest":"1.5.0"}}