{"id":17437290,"url":"https://github.com/blixt/js-workerproxy","last_synced_at":"2026-01-22T14:59:53.181Z","repository":{"id":14018168,"uuid":"16719964","full_name":"blixt/js-workerproxy","owner":"blixt","description":"Proxies function calls to web workers.","archived":false,"fork":false,"pushed_at":"2014-03-08T21:16:14.000Z","size":288,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-11T15:58:40.147Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/blixt.png","metadata":{"files":{"readme":"README.md","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}},"created_at":"2014-02-11T04:58:45.000Z","updated_at":"2020-12-29T14:27:52.000Z","dependencies_parsed_at":"2022-08-25T17:21:49.595Z","dependency_job_id":null,"html_url":"https://github.com/blixt/js-workerproxy","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/blixt/js-workerproxy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blixt%2Fjs-workerproxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blixt%2Fjs-workerproxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blixt%2Fjs-workerproxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blixt%2Fjs-workerproxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blixt","download_url":"https://codeload.github.com/blixt/js-workerproxy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blixt%2Fjs-workerproxy/sbom","scorecard":{"id":243564,"data":{"date":"2025-08-11","repo":{"name":"github.com/blixt/js-workerproxy","commit":"8e7649e1392a1e0d42e0fabce6245916fdc8fb01"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-17T07:05:06.549Z","repository_id":14018168,"created_at":"2025-08-17T07:05:06.549Z","updated_at":"2025-08-17T07:05:06.549Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28664827,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T14:01:31.714Z","status":"ssl_error","status_checked_at":"2026-01-22T13:59:23.143Z","response_time":144,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-10-17T11:39:47.574Z","updated_at":"2026-01-22T14:59:53.160Z","avatar_url":"https://github.com/blixt.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Worker Proxy\n============\n\nThis is a package to make it easy to proxy calls between a web app and\none or more HTML5 Web Workers.\n\nTo use it, you just wrap the Worker instance with this package:\n\n```js\nvar proxy = workerproxy(new Worker('my-worker.js'));\n// Note: This might fail in browsers that don't support Harmony proxies.\n// See the easy fix and explanation further down.\nproxy.greet('Blixt', function (err, message) {\n  if (err) alert('Oopsies! ' + err.message);\n  else alert(message);\n});\n```\n\nFor the Worker to understand calls, you also need to wrap the object\nthat has the functions you want to call in the Worker code:\n\n```js\n// In my-worker.js:\nworkerproxy({\n  greet: function (name, callback) {\n    callback(null, 'Hello, ' + name + '!');\n  }\n});\n```\n\nAs you can see, the functions in the Worker are always expected to call\ncallbacks. Even though this may seem unnecessary at first, the thinking\nis that since the calls between the app and the Worker will always be\ndone asynchronously, it's best to model your code around that fact. The\ncallbacks are in the Node.js style, which means they take an error as\nthe first argument, then any number of success values.\n\n\nHelper options\n--------------\n\nIf you are writing a very simple Worker and don't want to have to think\nabout callbacks, you can enable auto callbacks (and automatic catching\nof errors):\n\n```js\n// In my-worker.js:\nvar options = {autoCallback: true, catchErrors: true};\nworkerproxy({\n  greet: function (name) {\n    if (!name) throw new Error('No name specified!');\n    return 'Hello, ' + name + '!';\n  }\n}, options);\n```\n\n\nBrowsers that don't support Harmony Proxies\n-------------------------------------------\n\nIf you want to support browsers that don't yet support Harmony Proxies,\nyou may need to do some extra work. While workerproxy will let the app\nknow what functions it has available, that will take a few milliseconds\nto propagate. So if you try to call the proxy immediately, it may fail.\nThe solution to this is to specify the names of the functions you want\nto be able to call immediately:\n\n```js\n// In your web app:\nvar proxy = workerproxy(new Worker('my-worker.js'), {\n  functionNames: ['greet']\n});\n\n// This will now work even if the browser doesn't support Proxy.\nproxy.greet('Blixt', function (err, message) {\n  if (err) alert('Oopsies! ' + err.message);\n  else alert(message);\n});\n```\n\n\nTransferable objects\n--------------------\n\nThis package also supports transferable objects both ways. To mark an\nobject for transfer, call the `transfer` method on the function that\nyou would normally call (the method on the proxy for owner→worker and\nthe callback for worker→owner). Then pass in the list of objects that\nyou want to mark as the first argument, followed by the arguments you\nwould normally pass in.\n\nHere's a short example:\n\n```js\nvar api = require('workerproxy')(new Worker('worker.js'));\n\nvar buffer = new ArrayBuffer(100);\napi.fillBuffer.transfer([buffer], buffer, function (err, buffer) {\n  var array = new Uint8Array(buffer);\n  console.log('Got buffer back:', array);\n});\n```\n\nThe `worker.js` file would look like this:\n\n```js\nrequire('workerproxy')({\n  fillBuffer: function (buffer, callback) {\n    var array = new Uint8Array(buffer);\n    for (var i = 0; i \u003c array.length; i++) {\n      array[i] = Math.random() * 255;\n    }\n    callback.transfer([buffer], null, buffer);\n  }\n});\n```\n\n\nDistribution of calls to multiple Workers\n-----------------------------------------\n\nThe last major feature of this package is that it supports taking a list\nof Workers. It will then distribute your calls between the Workers so\nthat the first available Worker will get it (a Worker is considered\navailable once it has called the `callback` function):\n\n```js\n// In your web app:\nvar proxy = workerproxy([\n  new Worker('my-worker.js'),\n  new Worker('my-worker.js'),\n  new Worker('my-worker.js')\n]);\n```\n\nAll calls will now be distributed between the three Workers. Obviously\nyou want to ensure that all Workers can handle the calls and return the\nsame type of data.\n\nIn some cases you may want to send the same call to all workers, and for\nthat you can use the `broadcast` method on the function that you would\nnormally call:\n\n```js\nproxy.greet.broadcast('Blixt', function (err, message) {\n  // This will be called once for every worker!\n  console.log(message);\n});\n```\n\n\nInstalling with NPM\n===================\n\n```bash\nnpm install --save workerproxy\n```\n\n\nExamples\n========\n\n\nVanilla JavaScript\n------------------\n\nSee the `examples` directory for some simple examples.\n\n\nCommonJS\n--------\n\nTo call functions in a worker, wrap it with the `workerproxy` package,\nthen call methods on the returned object as you normally would. Note\nthat the last argument should always be a callback that takes an error\nargument followed by any number of values.\n\n```js\nvar api = require('workerproxy')(worker);\napi.greet('World', function (err, response) {\n  console.log('Worker said:', response);\n});\n```\n\nHere's how you define the API in the worker file. Note that the last\nargument will always be a function to call when you want to return a\nvalue, even if your function is synchronous. This is so that the API\nmaps 1:1 between how it is defined and how it is called.\n\n```js\nrequire('workerproxy')({\n  greet: function (name, callback) {\n    callback(null, 'Hello, ' + name + '!');\n  }\n});\n```\n\n\nOptions\n=======\n\nSince there are two sides to the worker proxy, the set of options\ndepends on which \"side\" you're setting up.\n\n\nOptions in web app\n------------------\n\n\n### `functionNames` (default `[]`)\n\nA list of function names that are specified in the Worker. The reason\nthis option exists is so that we can support browsers that don't have\nthe Harmony Proxy object, which allows creating getters for properties\nthat don't exist on an object. The names in `functionNames` will be\nadded to a fake proxy object which is then returned, so that you can\ncall those functions.\n\nNote that the full list of function names will be added to the fake\nproxy object automatically, but in an asynchronous manner. So if you\nwant to guarantee that the functions are available synchronously, use\nthis option.\n\n\n### `timeCalls` (default `false`)\n\nWhether to log the time it takes for calls to finish. This requires that\nthe browser supports `console.time` and `console.timeEnd`.\n\n\n\nOptions in Worker\n-----------------\n\n\n### `autoCallback` (default `false`)\n\nAutomatically call the callback with the return value of the function.\nNote that the callback will *always* be called (unless an exception is\nthrown) even if you already called it earlier in your function, or\ndidn't return a value (then it will be called with `undefined`).\n\nIf you want to prevent this behavior for a single function, you can call\n`callback.disableAuto()` in that function:\n\n```js\nworkerproxy({\n  greet: function (name) {\n    return 'Hello, ' + name + '!';\n  },\n\n  getName: function (id, callback) {\n    // We can't return a value immediately, so disable auto callback.\n    callback.disableAuto();\n\n    lookupUser(id, function (err, info) {\n      callback(err, info.name);\n    });\n  }\n}, {autoCallback: true});\n```\n\n\n### `catchErrors` (default `false`)\n\nCatch errors in proxied functions and automatically respond with an\nerror callback instead of throwing the error in the worker.\n\n**Example using `catchErrors`:**\n\n```js\n// worker.js\n\nvar store = {};\n\nvar functions = {\n  get: function (key, callback) {\n    if (!store.hasOwnProperty(key)) throw new Error('Key not found');\n    callback(null, store[key]);\n  },\n  set: function (key, value, callback) {\n    if (key in store \u0026\u0026 !store.hasOwnProperty(key)) {\n      throw new Error('Invalid key');\n    }\n\n    store[key] = value;\n    callback(null);\n  }\n};\n\n// CommonJS:\nrequire('workerproxy')(functions, {catchErrors: true});\n\n// Vanilla JavaScript:\ncreateWorkerProxy(functions, {catchErrors: true});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblixt%2Fjs-workerproxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblixt%2Fjs-workerproxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblixt%2Fjs-workerproxy/lists"}