{"name":"webworkify","version":"1.3.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":"aa591d74805f6cbe0ab2734e2ff7878184cac550","bugs":{"url":"https://github.com/substack/webworkify/issues"},"_id":"webworkify@1.3.0","_shasum":"58185dc382f0f0f27fb7d47ff181d9c88a65227c","_from":".","_npmVersion":"3.9.0","_nodeVersion":"5.7.1","_npmUser":{"name":"anandthakker","email":"vestibule@anandthakker.net"},"dist":{"shasum":"58185dc382f0f0f27fb7d47ff181d9c88a65227c","tarball":"http://registry-npm.ywwl.com/webworkify/download/webworkify-1.3.0.tgz","integrity":"sha512-yOzq51kKfv0NEiKi6AXpudqTJtPZTipJAjv8f1BsibwT+5OqgApsWe1OiHs0PZdmQ96LksSuR6Dz7GgpZ4cYlw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBVW9thQ8h9aAQoaUTWYsAkZ0FHJBVTnoDGgV+V2iUhxAiBG2z5AGBDNjMnj2MBMaDNcQ7reOv64CKS6qmFVc2La4Q=="}],"size":3572,"noattachment":false,"key":"/webworkify/-/webworkify-1.3.0.tgz"},"maintainers":[{"name":"anandthakker","email":"vestibule@anandthakker.net"},{"name":"substack","email":"substack@gmail.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/webworkify-1.3.0.tgz_1465997050076_0.04521094006486237"},"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":1465997053557,"_cnpm_publish_time":1465997053557,"dist-tags":{"latest":"1.5.0"}}