{"id":13396843,"url":"https://github.com/softvar/super-workers","last_synced_at":"2026-03-04T05:01:51.974Z","repository":{"id":57146617,"uuid":"105398497","full_name":"softvar/super-workers","owner":"softvar","description":":horse: Distribute load on front-end via parallelism","archived":false,"fork":false,"pushed_at":"2019-11-16T15:26:22.000Z","size":824,"stargazers_count":95,"open_issues_count":2,"forks_count":13,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-05-07T05:27:31.076Z","etag":null,"topics":["child-process","hacktoberfest","highly-parallelized-algorithm","jankfree","multi-threading","parallel-computing","performance-boost","priority-queue","queue-tasks","queue-workers","thread-pool","web-worker","worker-pool"],"latest_commit_sha":null,"homepage":"http://softvar.github.io/super-workers","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/softvar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["softvar"],"patreon":"softvar","open_collective":"softvar","custom":["https://paypal.me/softvar"]}},"created_at":"2017-09-30T20:22:52.000Z","updated_at":"2024-07-11T18:53:26.000Z","dependencies_parsed_at":"2022-08-29T19:41:06.436Z","dependency_job_id":null,"html_url":"https://github.com/softvar/super-workers","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/softvar/super-workers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softvar%2Fsuper-workers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softvar%2Fsuper-workers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softvar%2Fsuper-workers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softvar%2Fsuper-workers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/softvar","download_url":"https://codeload.github.com/softvar/super-workers/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softvar%2Fsuper-workers/sbom","scorecard":{"id":836212,"data":{"date":"2025-08-11","repo":{"name":"github.com/softvar/super-workers","commit":"6e2b3fcb70775f743de26d81e2ece3204649b3c0"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Code-Review","score":0,"reason":"Found 1/29 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":"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":"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":"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":"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":"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":"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":"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"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 2 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"105 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-cwfw-4gq5-mrqx","Warn: Project is vulnerable to: GHSA-g95f-p29q-9xw4","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-x9w5-v3q2-3rhw","Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-9vvw-cc9w-f27h","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-hr2v-3952-633q","Warn: Project is vulnerable to: GHSA-vh7m-p724-62c2","Warn: Project is vulnerable to: GHSA-r9p9-mrjm-926w","Warn: Project is vulnerable to: GHSA-434g-2637-qmqr","Warn: Project is vulnerable to: GHSA-49q7-c7j4-3p7m","Warn: Project is vulnerable to: GHSA-977x-g7h5-7qgw","Warn: Project is vulnerable to: GHSA-f7q4-pwc6-w24p","Warn: Project is vulnerable to: GHSA-fc9h-whq2-v747","Warn: Project is vulnerable to: GHSA-vjh7-7g9h-fjfh","Warn: Project is vulnerable to: GHSA-j4f2-536g-r55m","Warn: Project is vulnerable to: GHSA-r7qp-cfhv-p84w","Warn: Project is vulnerable to: GHSA-4gmj-3p3h-gm8h","Warn: Project is vulnerable to: GHSA-qrmc-fj45-qfc2","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-8r6j-v8pm-fqw3","Warn: Project is vulnerable to: MAL-2023-462","Warn: Project is vulnerable to: GHSA-xf7w-r453-m56c","Warn: Project is vulnerable to: GHSA-q42p-pg8m-cqh6","Warn: Project is vulnerable to: GHSA-w457-6q6x-cgp9","Warn: Project is vulnerable to: GHSA-62gr-4qp9-h98f","Warn: Project is vulnerable to: GHSA-f52g-6jhx-586p","Warn: Project is vulnerable to: GHSA-2cf5-4w76-r9qv","Warn: Project is vulnerable to: GHSA-3cqr-58rm-57f8","Warn: Project is vulnerable to: GHSA-g9r4-xpmj-mj65","Warn: Project is vulnerable to: GHSA-q2c6-c6pm-g3gh","Warn: Project is vulnerable to: GHSA-765h-qjxv-5f44","Warn: Project is vulnerable to: GHSA-f2jv-r9rf-7988","Warn: Project is vulnerable to: GHSA-44pw-h2cw-w3vq","Warn: Project is vulnerable to: GHSA-jp4x-w63m-7wgm","Warn: Project is vulnerable to: GHSA-c429-5p7v-vgjp","Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj","Warn: Project is vulnerable to: GHSA-6x33-pw7p-hmpq","Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37","Warn: Project is vulnerable to: GHSA-4hpf-3wq7-5rpr","Warn: Project is vulnerable to: GHSA-f522-ffg8-j8r6","Warn: Project is vulnerable to: GHSA-2pr6-76vf-7546","Warn: Project is vulnerable to: GHSA-8j8c-7jfh-h6hx","Warn: Project is vulnerable to: GHSA-896r-f27r-55mw","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-282f-qqgm-c34q","Warn: Project is vulnerable to: GHSA-7x7c-qm48-pq9c","Warn: Project is vulnerable to: GHSA-rc3x-jf5g-xvc5","Warn: Project is vulnerable to: GHSA-76p3-8jx3-jpfq","Warn: Project is vulnerable to: GHSA-3rfm-jhwj-7488","Warn: Project is vulnerable to: GHSA-hhq3-ff78-jv3g","Warn: Project is vulnerable to: GHSA-jf85-cpcp-j695","Warn: Project is vulnerable to: GHSA-fvqr-27wr-82fm","Warn: Project is vulnerable to: GHSA-4xc9-xhrj-v574","Warn: Project is vulnerable to: GHSA-x5rq-j2xg-h7qm","Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-82v2-mx6x-wq7q","Warn: Project is vulnerable to: GHSA-4xcv-9jjx-gfj3","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-w9mr-4mfr-499f","Warn: Project is vulnerable to: GHSA-q75g-2496-mxpp","Warn: Project is vulnerable to: GHSA-6fx8-h7jm-663j","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-h7cp-r72f-jxh6","Warn: Project is vulnerable to: GHSA-v62p-rq8g-8h59","Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp","Warn: Project is vulnerable to: GHSA-6g33-f262-xjp4","Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-fxwf-4rqh-v8g3","Warn: Project is vulnerable to: GHSA-25hc-qcg6-38wj","Warn: Project is vulnerable to: GHSA-xfhh-g9f5-x4m4","Warn: Project is vulnerable to: GHSA-qm95-pgcg-qqfq","Warn: Project is vulnerable to: GHSA-cqmj-92xf-r6r9","Warn: Project is vulnerable to: GHSA-2m39-62fm-q8r3","Warn: Project is vulnerable to: GHSA-mf6x-7mm4-x2g7","Warn: Project is vulnerable to: GHSA-j44m-qm6p-hp7m","Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9","Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh","Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36","Warn: Project is vulnerable to: GHSA-52f5-9888-hmc6","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-7p7h-4mm5-852v","Warn: Project is vulnerable to: GHSA-xc7v-wxcw-j472","Warn: Project is vulnerable to: GHSA-cf4h-3jhx-xvhq","Warn: Project is vulnerable to: GHSA-mgfv-m47x-4wqp","Warn: Project is vulnerable to: GHSA-wr3j-pwj9-hqq6","Warn: Project is vulnerable to: GHSA-5v72-xg48-5rpm","Warn: Project is vulnerable to: GHSA-72mh-269x-7mh5","Warn: Project is vulnerable to: GHSA-h4j5-c7cj-74xg","Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh","Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-23T19:07:39.010Z","repository_id":57146617,"created_at":"2025-08-23T19:07:39.011Z","updated_at":"2025-08-23T19:07:39.011Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30071895,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-04T03:25:38.285Z","status":"ssl_error","status_checked_at":"2026-03-04T03:25:05.086Z","response_time":59,"last_error":"SSL_read: 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":["child-process","hacktoberfest","highly-parallelized-algorithm","jankfree","multi-threading","parallel-computing","performance-boost","priority-queue","queue-tasks","queue-workers","thread-pool","web-worker","worker-pool"],"created_at":"2024-07-30T18:01:04.520Z","updated_at":"2026-03-04T05:01:51.949Z","avatar_url":"https://github.com/softvar.png","language":"JavaScript","readme":"\u003ch1 align=\"center\"\u003esuper-workers\u003c/h1\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"images/super-workers-white.png\" alt=\"Super Workers\"/\u003e\n\u003c/div\u003e\n\u003cdiv align=\"center\"\u003e\n  \u003cstrong\u003eDistribute load on front-end via parallelism\u003c/strong\u003e\n\u003c/div\u003e\n\u003cdiv align=\"center\"\u003e\n  A \u003ccode\u003e5.5kb\u003c/code\u003e JavaScript library for executing multiple parallel tasks on front-end\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ch3\u003e\n    \u003ca href=\"http://varunmalhotra.xyz/super-workers\"\u003e\n      Website\n    \u003c/a\u003e\n    \u003cspan\u003e | \u003c/span\u003e\n    \u003ca href=\"http://varunmalhotra.xyz/super-workers#live-demo\"\u003e\n      Live Demo\n    \u003c/a\u003e\n    \u003cspan\u003e | \u003c/span\u003e\n    \u003ca href=\"https://github.com/softvar/super-workers#contributing\"\u003e\n      Contributing\n    \u003c/a\u003e\n    \u003cspan\u003e | \u003c/span\u003e\n    \u003ca href=\"https://gitter.im/super-workers/Lobby#\"\u003e\n      Chat\n    \u003c/a\u003e\n  \u003c/h3\u003e\n\u003c/div\u003e\n\n\u003cbr /\u003e\n\u003cbr /\u003e\n\n[![npm version](https://badge.fury.io/js/super-workers.svg)](https://www.npmjs.com/package/super-workers) [![npm](https://img.shields.io/npm/dt/super-workers.svg)](https://www.npmjs.com/package/super-workers) [![Build Status](http://img.shields.io/travis/softvar/super-workers/master.svg?style=flat)](http://travis-ci.org/softvar/super-workers) [![Coverage Status](https://coveralls.io/repos/github/softvar/super-workers/badge.svg?branch=master)](https://coveralls.io/github/softvar/super-workers?branch=master) ![](http://img.badgesize.io/softvar/super-workers/master/dist/super-workers.min.js?compression=gzip\u0026color=blue) [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://paypal.me/softvar)\n\n\u003c!-- [![NPM](https://nodei.co/npm/super-workers.png?downloads=true)](https://nodei.co/npm/super-workers/) --\u003e\n\n\u003c!-- \u003ca href=\"https://news.ycombinator.com/item?id=14041400\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/softvar/super-workers/master/images/hn.png\" width=\"150\" height=\"20\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://www.producthunt.com/posts/super-workers\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/softvar/super-workers/master/images/product_hunt.png\" width=\"100\" height=\"20\"/\u003e\u003c/a\u003e --\u003e\n\n### Table of Contents\n* [Features](#features)\n* [Installation](#installation)\n* [Flow diagram](#flow-diagram)\n* [Usage](#usage)\n* [API](#api)\n* [Browser support](#browser-support)\n* [Development Stack](#development-stack)\n* [Process](#process)\n* [Scripts](#scripts)\n* [Contributing](#contributing)\n* [Authors](#authors)\n* [Copyright and license](#copyright-and-license)\n\n### Features\n\n1. Run multiple tasks parallelly without blocking the main thread.\n2. Jank-free pages since all the computations take place in worker-thread and not in main-thread (thereby speed and performance at the same time).\n3. On-demand initialization of web-workers based on task-queue size. Configure minimum and a maximum number of web-workers or let library smartly decide based on hardware concurrency number.\n4. Configure task(set priority, time-to-live) and *Priority Task Queue Management System(PTQMS)* will take care of the queue handling and execution.\n5. Termination of idle(non-used) web-workers for better performance(can be opt-out while configuring). Set minimum number of web-workers to restrict their termination when idle, so that they remain present for future needs.\n6. Fully fledged API to get all the information regarding tasks and workers at any given point of time.\n7. Promise based execution of tasks i.e. perform different actions on success or failure. Useful for the re-attempting failed task.\n8. Define callbacks to be get triggered at various events. Eg. on the successful execution of the task, on exceeding the time limit of task execution, etc.\n9. Exports in a `UMD` format i.e. library works everywhere (nodejs doesn't have the concept of workers but have a child-process concept which is not handled in this lib).\n10. Only `~5.5 KB` gzipped.\n\n### Installation\n\n1. Via [npm](https://www.npmjs.com/)\n\n```\n$ npm install super-workers\n```\n\n2. Via [yarn](https://yarnpkg.com/en/)\n\n```\n$ yarn add super-workers\n```\n\n3. Via [bower](https://bower.io/)\n\n```\n$ bower install super-workers\n```\n\n4. Download source - [Link](https://github.com/softvar/super-workers/archive/1.0.0.tar.gz)\n\n\u003c!-- 3. Via [cdnjs](https://cdnjs.com), using `\u003cscript\u003e` tag\n\n```\n\u003cscript type=\"text/javascript\" src=\"https://cdnjs.cloudflare.com/ajax/libs/super-workers/1.0.0/super-workers.min.js\"\u003e\u003c/script\u003e\n```\n\n**Note**: Use the desired version of the library in place of `1.0.0`. Checkout [cdnjs super-workers](https://cdnjs.com/libraries/super-workers). --\u003e\n\n### Flow Diagram\n\n**Aim** - To be able to run multiple tasks simultaneously without freezing the web-page\n\n- Tasks are queued as they arrive.\n- Task Queue Process Management(TQPM) processes the queue and based on tasks' priority, it reorders the queue.\n- Workers are spawned as and when required based on number of tasks and configuration.\n- Availability of workers decide the number of tasks getting processed.\n- Completion of a task allow the next queued task to be get executed.\n\nBelow diagram will aid in understanding the flow better\n\n\u003c!-- https://raw.githubusercontent.com/softvar/super-workers/master/parent-tab-communication.jpg --\u003e\n\u003cimg src=\"images/super-workers-flow-diagram.png\" /\u003e\n\n---\n\n#### Explanation of diagram\n\n***Setting the workers configuration***\n\nLets have the following worker configuration:\n\n- minimum number of workers always available to execute tasks - `minWorkers = 1`\n- maximum number of workers that should be spwaned irrespective of the number of tasks in the queue - `maxWorkers = 3`. This number will restrict registering of workers more than this number. We can not set this number randomly since it depend on the number of cores in a machine. By default, the library will pick it for you using `navigator.hardwareConcurrency` or it's polyfill. Setting it too high will not boost queue processing as it becomes constant after the threshold(totally depends upon the hardware configuration).\n\n---\n\n***Task Queue Process Management***\n\n- Initially the task queue(TQ) is empty.\n- Task T1, T2, and T3 arrive in the same order but with different priorities.\n- Task T1 is of `medium` priority.\n- T1 is pushed into queue and `Task Queue Process Management` reorders the `TQ` based on tasks' prioriies.\n- After proper ordering of tasks, task is ready to be executed by the web-worker\n\n---\n\n***Web worker Execution***\n\n- Firstly, availability of workers is checked.\n- If there is no worker available, there are two cases.\n  i) All workers are busy i.e. maxWorkers number has been reached, so, tasks need to be in queue for more time before they can be picked up for execution.\n  ii) No worker has been spwaned yet and `maxNumbers` is greater than the number of spawned workers.\n- If the condition for spwaning a new worker passes, a web-worker is registered and the task is removed from the TQ and is executed.\n- Worker(s) execute(s) the task(s) and return a `promise`.\n- After completion of task, the process is re-run to execute next pending tasks in the `TQ`.\n\n### Usage\n\n##### Create an instance / reference before using.\n\n**Main Thread**\n\n```\nvar sp = new SuperWorkers.MainThread({\n    url: 'js/my-worker.js'\n});\n```\n\n`Constructor` accepts a configurable `Object` with the following keys.\n\n* `url`: The path of worker script\n* `maxWorkers`: Maximum workers that can be spawned to execute parallel tasks. Depends on CPU cores(hardwareConcurrency) of a machine\n* `minWorkers`: Minimum workers that should be always available to execute parallel tasks (one worker should alive if tasks keep coming).\n* `killWorkersAfterJob`: Kills all the idle workers(no longer required as tasks are completed) except one worker.\n\n| Config Keys               |     default    |      accepts                              |\n| ---------------------     | -------------- | ----------------------------------------- |\n| **url**                   |     Undefined  |            String(url)                    |\n| **maxWorkers**            |     3          |            Number                         |\n| **minWorkers**            |     1          |            Number                         |\n| **killWorkersAfterJob**   |     true       |            Boolean                        |\n\n***Note***: Url of the worker script is mandatory.\n\n\n**Worker Thread**\n\n```\n// Include the library\nimportScripts('path/to/super-workers.min.js');\n// It will expose `SuperWorkers`\n```\n\n```\nvar child = new SuperWorkers.WorkerThread();\n```\n\n`Constructor` doesn't need any configuration but would accept a configurable `Object` with different keys that would not be used by the library.\n\n### API\n\nRefer [above section](#create-an-instance--reference-before-using) on how to create an instance before hitting API methods.\n\n##### Main Thread Methods\n\n* **`exec`**\n\n  Executes a task\n\n  |   Parameter   |        Description                                   |  Accepts    |\n  | ------------- | ---------------------------------------------------- |  ---------  |\n  |     method    |     Function that needs to be executed               |  Function(Offloading) / String(Onloading) |\n  |     params    |     List of arguments that the function accepts      |  Array      |\n  |     config    |     Task config                                      |  Object     |\n\n  ```\n    function add (a, b, timeout) {\n      var p = SuperWorkers.Promise.defer();\n\n      setTimeout(function () {\n          return p.resolve(a + b);\n      }, timeout || 0);\n\n      return p.promise;\n    }\n\n    var taskConfig = {\n      name: 'Add',\n      priority: 'LOW',\n    };\n    sp.exec(add, [1, 2, 2000], taskConfig); // Offloading the method\n  ```\n\n  Define `add` mthod in worker script\n  ```\n    importScripts('path/to/super-workers.min.js');\n\n    function add (a, b) {\n      return a + b;\n    }\n  ```\n\n  In Main thread,\n\n  ```\n    var taskConfig = {\n      name: 'Add',\n      priority: 'HIGH',\n    };\n    sp.exec('add', [1, 2, 2000], taskConfig); // Onloading the method\n  ```\n\n* **`getAllWorkers`**\n\n  Returns the list of all the workers.\n  ```\n    sp.getAllWorkers();\n  ```\n\n* **`getActiveWorkers`**\n\n  Returns the list of all `active` workers.\n\n  ```\n    sp.getActiveWorkers();\n  ```\n\n* **`getIdleWorkers`**\n\n  Returns the list of all `idle` workers.\n\n  ```\n    sp.getIdleWorkers();\n  ```\n\n* **`getTerminatedWorkers`**\n\n  Returns the list of all the `terminated` workers.\n\n  ```\n    sp.getTerminatedWorkers();\n  ```\n\n* **`terminateAllWorkers`**\n\n  Termiates all the workers irrespective of the status.\n\n  ```\n    sp.terminateAllWorkers();\n  ```\n\n* **`terminateWorker`**\n\n  Terminated a particular worker by passing the worker-id.\n\n  |   Parameter   |        Description                       |\n  | ------------- | ---------------------------------------- |\n  |     id        |     id of the worker to be terminated    |\n\n  ```\n    sp.terminateWorker('57cd47da-d98e-4a2d-814c-9b07cb51059c');\n  ```\n\n* **`broadCastAll`**\n\n  Sends a same `message` to all the `active` workers (Message would be sent via `postMessage` API)\n\n  |   Parameter   |        Description          |\n  | ------------- | --------------------------- |\n  |     msg       |        msg to be sent        |\n\n  ```\n    sp.broadCastAll('Hello my dear Child! A greeting from Parent.'});\n  ```\n\n* **`broadCastTo`**\n\n  Sends a `message` to a particular `active` worker (Message would be sent via `postMessage` API)\n\n  |   Parameter   |        Description               |\n  | ------------- | -------------------------------- |\n  |     id        |  id of the worker to send a msg  |\n  |     msg       |        msg to be sent            |\n\n  ```\n    sp.broadCastTo('57cd47da-d98e-4a2d-814c-9b07cb51059c', 'Hey! Can you run the script: worker.js? Thanks!');\n  ```\n\n#####  Child(Worker) Thread Methods\n\n* **`sendMessage`**\n\n  Sends a message to Main thread.\n\n  |   Parameter   |        Description            |   Accepts    |\n  | ------------- | ----------------------------- | ------------ |\n  |     msg       |        msg to be sent          |    Object    |\n  |     origin    |        origin                 |    String    |\n\n  ```\n    child.sendMessage(obj, `'*'`);\n  ```\n\n* **`exposeMethods`**\n\n  It works as a proxy. Methods which needs to be onloaded should be exposed before they can used in main thread.\n\n  |   Parameter   |        Description            |  Accepts   |\n  | ------------- | ----------------------------- | ---------- |\n  |     methods   |        list of all functions  |   Object   |\n\n  ```\n    child.exposeMethods({\n      add: function (a, b) {\n        return a + b;\n      }\n    });\n  ```\n\n##### Task Queue Methods\n\n* **`get`**\n\n  Returns the task.\n\n  |   Parameter   |        Description                       |\n  | ------------- | ---------------------------------------- |\n  |     id        |     id of the task                       |\n\n  ```\n    sp.taskQueue.get('34cd47da-d98e-4a2d-814c-9b07cb510578');\n  ```\n\n* **`getAll`**\n\n  Returns the list of all `all` tasks.\n\n  ```\n    sp.taskQueue.getAll();\n  ```\n\n* **`getActive`**\n\n  Returns the list of all `active` tasks.\n\n  ```\n    sp.taskQueue.getActive();\n  ```\n\n* **`getCompleted`**\n\n  Returns the list of all `completed` tasks.\n\n  ```\n    sp.taskQueue.getCompleted();\n  ```\n\n* **`getFailed`**\n\n  Returns the list of all the `failed` tasks.\n\n  ```\n    sp.taskQueue.getFailed();\n  ```\n\n* **`tasks`** and **`allTasks`**\n\n  Returns tasks which are in queue.\n  ```\n    sp.taskQueue.tasks\n  ```\n\n  Returns all the tasks i.e. pending, queued, active and completed/failed.\n  ```\n    sp.taskQueue.allTasks\n  ```\n\n### Browser Support\n\nTested in Chrome, Firefox and IE(versions \u003e= 9).\n\n### Sites using super-workers\n\n* *[Add your site]* - See [Contributing](#contributing) section\n\n### Development Stack\n\n* Webpack based `src` compilation \u0026 bundling and `dist` generation.\n* ES6 as a source of writing code.\n* Exports in a [UMD](https://github.com/umdjs/umd) format so the library works everywhere.\n* Linting with [ESLint](http://eslint.org/).\n* ES6 test setup with [Karma](https://karma-runner.github.io/1.0/index.html), [Jasmine](https://jasmine.github.io/2.0/introduction.html) and [isparta](https://github.com/deepsweet/isparta-loader).\n* Test coverage with [Istanbul]() and [Coveralls](https://coveralls.io/).\n\n### Process\n\n```\nES6 source files\n       |\n       |\n    webpack\n       |\n       +--- babel, eslint\n       |\n       o--- tests and covergae\n       |\n  ready to use\n     library\n  in UMD format\n```\n\n### Scripts\n\n* `npm run build` - produces production version(minified) of the library under the `dist` folder\n* `npm run dev` - produces development version(un minified) of the library and runs a watcher to detect file changes.\n* `npm run test` - well ... it runs the tests :)\n\n### Contributing\n\n[CONTRIBUTING.md](CONTRIBUTING.md)\n\n**Note:** If adding site to the list of *sites using super-workers*, please mention where to verify this in the PR description.\n\n### Authors\n**[Varun Malhotra](http://varunmalhotra.xyz)** [@softvar](https://github.com/softvar)\n\n### Feel like helping?\nPlease don't hesitate to buy me a cup of coffee :)\n\n[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://paypal.me/softvar)\n\n### Copyright and license\n\n\u003eThe [MIT license](https://opensource.org/licenses/MIT) (MIT)\n\u003e\n\u003eCopyright (c) 2017 Varun Malhotra\n\u003e\n\u003ePermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\u003e\n\u003eThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\u003e\n\u003eTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","funding_links":["https://github.com/sponsors/softvar","https://patreon.com/softvar","https://opencollective.com/softvar","https://paypal.me/softvar"],"categories":["Packages"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftvar%2Fsuper-workers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoftvar%2Fsuper-workers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftvar%2Fsuper-workers/lists"}