{"id":15365927,"url":"https://github.com/andywer/threadpool-js","last_synced_at":"2025-07-29T09:35:02.929Z","repository":{"id":7809406,"uuid":"9180033","full_name":"andywer/threadpool-js","owner":"andywer","description":"Javascript thread pool implementation using web workers.","archived":false,"fork":false,"pushed_at":"2015-10-30T14:18:33.000Z","size":6206,"stargazers_count":47,"open_issues_count":0,"forks_count":13,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-07-10T19:26:45.186Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/andywer.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":"2013-04-02T20:55:40.000Z","updated_at":"2023-05-30T12:30:15.000Z","dependencies_parsed_at":"2022-08-30T21:31:13.800Z","dependency_job_id":null,"html_url":"https://github.com/andywer/threadpool-js","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/andywer/threadpool-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andywer%2Fthreadpool-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andywer%2Fthreadpool-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andywer%2Fthreadpool-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andywer%2Fthreadpool-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andywer","download_url":"https://codeload.github.com/andywer/threadpool-js/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andywer%2Fthreadpool-js/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267663001,"owners_count":24123977,"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","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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-01T13:16:43.466Z","updated_at":"2025-07-29T09:35:02.899Z","avatar_url":"https://github.com/andywer.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## threadpool.js [![Build Status](https://travis-ci.org/andywer/threadpool-js.svg?branch=master)](https://travis-ci.org/andywer/threadpool-js) [![npm version](https://badge.fury.io/js/threadpool-js.svg)](http://badge.fury.io/js/threadpool-js) [![Bower version](https://badge.fury.io/bo/threadpool-js.svg)](http://badge.fury.io/bo/threadpool-js)\n\n__Deprecation notice: This package is near its end of life. Switch to [threads.js](https://github.com/andywer/threads.js) instead. It provides the same features plus additional ones and is generally more awesome :)__\n__PS: If you feel different about it, feel free to open an issue.__\n\n_threadpool.js_ is aimed to be a general-purpose multi-threading library for Javascript.\nIts key features are *portability* and *ease of use*. The library can either be used in a stand-alone fashion or as a *[require.js](http://requirejs.org/)* module.\n\n## Usage\n\nYou can add threadpool-js to your project using npm or bower:\n\n```bash\nnpm install --save threadpool-js\n# or\nbower install --save threadpool-js\n```\n\nOr just by adding this script tag:\n\n```html\n\u003cscript type=\"text/javascript\" src=\"http://andywer.github.io/threadpool-js/dist/threadpool.min.js\"\u003e\u003c/script\u003e\n```\n\n## Example use\n\nInclude the library at first. Just add the *threadpool.js* file to your project and include it per `\u003cscript\u003e` tag.\nAlternatively you may use *[require.js](http://requirejs.org/)* or require it as a node.js module when using *[browserify](http://browserify.org/)* or *[webpack](http://webpack.github.io/)*.\n\n```javascript\n// Init new threadpool with default size\nvar pool = new ThreadPool();\n\n// Spawn two threads\npool\n  .run(mythread, \"Hello\")\n  .done(function(result) {\n    document.write(\"Thread #1: \" + result);\n  });\npool\n  .run(mythread, \" World\")\n  .done(function(result) {\n    document.write(\"Thread #2: \" + result);\n  });\n\n// Hint: Keep in mind that you are free to use the done() and error() handlers\n//       on single jobs and the whole pool!\n\npool.allDone(function() {\n  document.write(\"All jobs are done.\");\n});\n\n// Thread logic\nfunction mythread (param, done) {\n  done( param.toUpperCase() );\n}\n```\n\n## Running external scripts\n\nYou can also choose to run another javascript file instead of passing a function:\n\n```javascript\n// Init new threadpool with default size\nvar pool = new ThreadPool();\n\n// Spawn thread running another script file\npool\n  .run(\"/path/to/script.js\", { foo: 'bar' })\n  .done(function(result) {\n    console.log(\"Job finished and returned: \", result);\n  });\n```\n\n## Using libraries in the worker code\n\nAssume that you want to use jQuery in your thread code. You cannot manipulate the DOM from there, but you might need some convenience methods. You can import other Javascript files into the scope of your thread code like this:\n\n```javascript\npool.run([\"/path/to/jQuery.min.js\"], function(param, done) { /* do something awesome */ });\n```\n\n\n## Support for transferable objects\n\nIf you want to pass large blobs to your workers efficiently, you may use a feature called [transferable objects](https://developer.mozilla.org/en/docs/Web/Guide/Performance/Using_web_workers#Passing_data_by_transferring_ownership_(transferable_objects)).\n\n_threadpool-js_ supports them. Just pass the array of buffers to transfer (after the worker parameter) to the pool's `run` method:\n\n```javascript\npool.run(mythread, {hash: \"sha512\", data: myUint8Array}, [myUint8Array.buffer]);\n```\n\n\n## Demo\n\nTry the [samples](http://andywer.github.io/threadpool-js/samples/index.html).\n\n(Use Chrome, Firefox, IE, or Opera)\n\nNote: IE support experimental\n\n## License\n\nThis library is published under the MIT license. See [LICENSE](https://raw.githubusercontent.com/andywer/threadpool-js/master/LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandywer%2Fthreadpool-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandywer%2Fthreadpool-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandywer%2Fthreadpool-js/lists"}