{"id":13555541,"url":"https://github.com/browserify/webworkify","last_synced_at":"2025-05-15T18:10:37.110Z","repository":{"id":49144464,"uuid":"11858687","full_name":"browserify/webworkify","owner":"browserify","description":"launch a web worker that can require() in the browser with browserify","archived":false,"fork":false,"pushed_at":"2024-12-21T09:59:10.000Z","size":23,"stargazers_count":418,"open_issues_count":7,"forks_count":39,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-05-13T12:53:36.177Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/browserify.png","metadata":{"files":{"readme":"readme.markdown","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-08-03T05:49:07.000Z","updated_at":"2025-02-13T01:28:14.000Z","dependencies_parsed_at":"2025-01-19T11:00:45.434Z","dependency_job_id":"14d4bb8b-7bf2-4d8d-a4f4-07ec49c976c8","html_url":"https://github.com/browserify/webworkify","commit_stats":{"total_commits":32,"total_committers":13,"mean_commits":"2.4615384615384617","dds":0.5625,"last_synced_commit":"baf2884256768aea6c36be1ea6e1efb2144fcfbc"},"previous_names":["substack/webworkify"],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/browserify%2Fwebworkify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/browserify%2Fwebworkify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/browserify%2Fwebworkify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/browserify%2Fwebworkify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/browserify","download_url":"https://codeload.github.com/browserify/webworkify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254394724,"owners_count":22063984,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T12:03:16.456Z","updated_at":"2025-05-15T18:10:37.069Z","avatar_url":"https://github.com/browserify.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","others"],"sub_categories":[],"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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrowserify%2Fwebworkify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrowserify%2Fwebworkify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrowserify%2Fwebworkify/lists"}