{"id":15459262,"url":"https://github.com/poolifier/poolifier-web-worker","last_synced_at":"2026-02-23T23:39:49.489Z","repository":{"id":198659931,"uuid":"701262362","full_name":"poolifier/poolifier-web-worker","owner":"poolifier","description":"Fast and small web worker pool","archived":false,"fork":false,"pushed_at":"2025-04-22T09:33:41.000Z","size":15754,"stargazers_count":44,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-22T10:56:37.981Z","etag":null,"topics":["browser","bun","deno","worker-pool"],"latest_commit_sha":null,"homepage":"https://jsr.io/@poolifier/poolifier-web-worker/doc","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/poolifier.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"open_collective":"poolifier","github":"poolifier"}},"created_at":"2023-10-06T09:17:32.000Z","updated_at":"2025-04-22T09:32:47.000Z","dependencies_parsed_at":"2023-11-20T11:26:54.284Z","dependency_job_id":"75db5332-c823-40a9-852b-024c233a5594","html_url":"https://github.com/poolifier/poolifier-web-worker","commit_stats":{"total_commits":3700,"total_committers":15,"mean_commits":"246.66666666666666","dds":0.6091891891891892,"last_synced_commit":"600b234fd905b6f6dec3e6374d343bc6b2eed735"},"previous_names":["poolifier/poolifier-deno","poolifier/poolifier-web-worker"],"tags_count":92,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poolifier%2Fpoolifier-web-worker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poolifier%2Fpoolifier-web-worker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poolifier%2Fpoolifier-web-worker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/poolifier%2Fpoolifier-web-worker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/poolifier","download_url":"https://codeload.github.com/poolifier/poolifier-web-worker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251734546,"owners_count":21635155,"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":["browser","bun","deno","worker-pool"],"created_at":"2024-10-01T23:05:50.600Z","updated_at":"2026-02-23T23:39:49.470Z","avatar_url":"https://github.com/poolifier.png","language":"JavaScript","readme":"\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/poolifier/poolifier/master/images/logo.png\" width=\"340px\" height=\"266px\"/\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n# Deno, Bun and browser Web Worker Pool\n\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![GitHub commit activity (master)](https://img.shields.io/github/commit-activity/m/poolifier/poolifier-web-worker/master?color=brightgreen\u0026logo=github)](https://github.com/poolifier/poolifier-web-worker/graphs/commit-activity)\n[![CI Workflow](https://github.com/poolifier/poolifier-web-worker/actions/workflows/ci.yml/badge.svg)](https://github.com/poolifier/poolifier-web-worker/actions/workflows/ci.yml)\n[![Code Coverage](https://sonarcloud.io/api/project_badges/measure?project=poolifier_poolifier-web-worker\u0026metric=coverage)](https://sonarcloud.io/dashboard?id=poolifier_poolifier-web-worker)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=poolifier_poolifier-web-worker\u0026metric=alert_status)](https://sonarcloud.io/dashboard?id=poolifier_poolifier-web-worker)\n[![Npm Version](https://badgen.net/npm/v/poolifier-web-worker?icon=npm)](https://www.npmjs.com/package/poolifier-web-worker)\n[![JSR Version](https://jsr.io/badges/@poolifier/poolifier-web-worker)](https://jsr.io/@poolifier/poolifier-web-worker)\n[![neostandard Javascript Code Style](\u003chttps://badgen.net/static/code style/neostandard/green\u003e)](https://github.com/neostandard/neostandard)\n[![Discord](https://badgen.net/discord/online-members/vXxZhyb3b6?icon=discord\u0026label=discord\u0026color=green)](https://discord.gg/vXxZhyb3b6)\n[![Open Collective](https://opencollective.com/poolifier/tiers/badge.svg)](https://opencollective.com/poolifier)\n[![PRs Welcome](https://badgen.net/static/PRs/welcome/green)](https://makeapullrequest.com)\n[![No Dependencies](\u003chttps://badgen.net/static/dependencies/no dependencies/green\u003e)](https://badgen.net/static/dependencies/nodependencies/green)\n\n\u003c/div\u003e\n\n## Why Poolifier?\n\nPoolifier is used to perform CPU and/or I/O intensive tasks on Deno, Bun or\nbrowser, it implements worker pools using\n[web worker API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API)\nmodule.\\\nWith poolifier you can improve your **performance** and resolve problems related\nto the event loop.\\\nMoreover you can execute your tasks using an API designed to improve the\n**developer experience**.\\\nPlease consult our [general guidelines](#general-guidelines).\n\n- Easy to use ✔\n- Fixed and dynamic pool size ✔\n- Easy switch from a pool type to another ✔\n- Performance\n  [benchmarks](https://github.com/poolifier/poolifier-web-worker/blob/master/benchmarks/README.md)\n  ✔\n- Multiple JS runtime support at zero cost abstraction ✔\n- No runtime dependencies ✔\n- Support for ESM and TypeScript ✔\n- Support for\n  [web worker API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API)\n  module ✔\n- Tasks distribution strategies ✔\n- Lockless tasks queueing ✔\n- Queued tasks rescheduling:\n  - Task stealing on idle ✔\n  - Tasks stealing under back pressure ✔\n  - Tasks redistribution on worker error ✔\n- Support for sync and async task function ✔\n- Support for abortable task function ✔\n- Support for multiple task functions:\n  - Queuing priority ✔\n  - Tasks distribution strategy ✔\n  - Worker node affinity ✔\n  - [CRUD](https://en.wikipedia.org/wiki/Create,_read,_update_and_delete)\n    operations at runtime ✔\n- General guidelines on pool choice ✔\n- Error handling out of the box ✔\n- Widely tested ✔\n- Active community ✔\n- Code quality\n  [![Bugs](https://sonarcloud.io/api/project_badges/measure?project=poolifier_poolifier-web-worker\u0026metric=bugs)](https://sonarcloud.io/dashboard?id=poolifier_poolifier-web-worker)\n  [![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=poolifier_poolifier-web-worker\u0026metric=code_smells)](https://sonarcloud.io/dashboard?id=poolifier_poolifier-web-worker)\n  [![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=poolifier_poolifier-web-worker\u0026metric=duplicated_lines_density)](https://sonarcloud.io/dashboard?id=poolifier_poolifier-web-worker)\n  [![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=poolifier_poolifier-web-worker\u0026metric=sqale_rating)](https://sonarcloud.io/dashboard?id=poolifier_poolifier-web-worker)\n  [![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=poolifier_poolifier-web-worker\u0026metric=reliability_rating)](https://sonarcloud.io/dashboard?id=poolifier_poolifier-web-worker)\n  [![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=poolifier_poolifier-web-worker\u0026metric=sqale_index)](https://sonarcloud.io/dashboard?id=poolifier_poolifier-web-worker)\n- Code security\n  [![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=poolifier_poolifier-web-worker\u0026metric=security_rating)](https://sonarcloud.io/dashboard?id=poolifier_poolifier-web-worker)\n  [![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=poolifier_poolifier-web-worker\u0026metric=vulnerabilities)](https://sonarcloud.io/dashboard?id=poolifier_poolifier-web-worker)\n\n## Table of contents\n\n- [Overview](#overview)\n- [Usage](#usage)\n  - [Deno](#deno)\n  - [Bun](#bun)\n  - [Browser](#browser)\n  - [Example code](#example-code)\n- [Deno and Bun versions](#deno-and-bun-versions)\n- [API](#api)\n- [General guidelines](#general-guidelines)\n- [Worker choice strategies](#worker-choice-strategies)\n- [Contribute](#contribute)\n- [Team](#team)\n- [License](#license)\n\n## Overview\n\nPoolifier contains\n[web worker](https://developer.mozilla.org/en-US/docs/Web/API/Worker/Worker)\npool implementation, you don't have to deal with\n[web worker API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API)\ncomplexity.\\\nThe first implementation is a fixed worker pool, with a defined number of\nworkers that are started at creation time and will be reused.\\\nThe second implementation is a dynamic worker pool, with a number of worker\nstarted at creation time (these workers will be always active and reused) and\nother workers created when the load will increase (with an upper limit, these\nworkers will be reused when active), the newly created workers will be stopped\nafter a configurable period of inactivity.\\\nYou have to implement your worker by extending the _ThreadWorker_ class.\n\n## Usage\n\n### Deno\n\n```shell\ndeno add jsr:@poolifier/poolifier-web-worker\n```\n\n**See\n[Deno examples](https://github.com/poolifier/poolifier-web-worker/blob/master/examples/deno/)\nfor more details**:\n\n- [Javascript](https://github.com/poolifier/poolifier-web-worker/blob/master/examples/deno/javascript/)\n- [Typescript](https://github.com/poolifier/poolifier-web-worker/blob/master/examples/deno/typescript/)\n\n### Bun\n\n#### npmjs\n\n```shell\nbun add poolifier-web-worker\n```\n\n#### JSR\n\n```shell\nbunx jsr add @poolifier/poolifier-web-worker\n```\n\n**See\n[Bun examples](https://github.com/poolifier/poolifier-web-worker/blob/master/examples/bun/)\nfor more details**:\n\n- [Typescript](https://github.com/poolifier/poolifier-web-worker/blob/master/examples/bun/typescript/)\n\n### Browser\n\n\u003c!-- x-release-please-start-version --\u003e\n\u003c!-- deno-fmt-ignore --\u003e\n\n```js\n\u003cscript type=\"module\"\u003eimport { ThreadWorker } from 'https://cdn.jsdelivr.net/npm/poolifier-web-worker@0.6.2/browser/mod.js'\u003c/script\u003e\n```\n\n```js\n\u003cscript type=\"module\"\u003e\nimport {\n  availableParallelism,\n  DynamicThreadPool,\n  FixedThreadPool,\n  PoolEvents,\n} from 'https://cdn.jsdelivr.net/npm/poolifier-web-worker@0.6.2/browser/mod.js'\n\u003c/script\u003e\n```\n\n\u003c!-- x-release-please-end --\u003e\n\n### Example code\n\nYou can implement a poolifier\n[web worker](https://developer.mozilla.org/en-US/docs/Web/API/Worker/Worker) in\na simple way by extending the class _ThreadWorker_:\n\n```js\n// adapt import to the targeted JS runtime\nimport { ThreadWorker } from '@poolifier/poolifier-web-worker'\n\nfunction yourFunction(data) {\n  // this will be executed in the worker thread,\n  // the data will be received by using the execute method\n  return { ok: 1 }\n}\n\nexport default new ThreadWorker(yourFunction, {\n  maxInactiveTime: 60000,\n})\n```\n\nInstantiate your pool based on your needs :\n\n```js\n// adapt import to the targeted JS runtime\nimport {\n  availableParallelism,\n  DynamicThreadPool,\n  FixedThreadPool,\n  PoolEvents,\n} from '@poolifier/poolifier-web-worker'\n\n// a fixed web worker pool\nconst pool = new FixedThreadPool(\n  availableParallelism(),\n  new URL('./yourWorker.js', import.meta.url),\n  {\n    errorEventHandler: (e) =\u003e {\n      console.error(e)\n    },\n  },\n)\n\npool.eventTarget?.addEventListener(\n  PoolEvents.ready,\n  () =\u003e console.info('Pool is ready'),\n)\npool.eventTarget?.addEventListener(\n  PoolEvents.busy,\n  () =\u003e console.info('Pool is busy'),\n)\n\n// or a dynamic web worker pool\nconst pool = new DynamicThreadPool(\n  Math.floor(availableParallelism() / 2),\n  availableParallelism(),\n  new URL('./yourWorker.js', import.meta.url),\n  {\n    errorEventHandler: (e) =\u003e {\n      console.error(e)\n    },\n  },\n)\n\npool.eventTarget?.addEventListener(\n  PoolEvents.full,\n  () =\u003e console.info('Pool is full'),\n)\npool.eventTarget?.addEventListener(\n  PoolEvents.ready,\n  () =\u003e console.info('Pool is ready'),\n)\npool.eventTarget?.addEventListener(\n  PoolEvents.busy,\n  () =\u003e console.info('Pool is busy'),\n)\n\n// the execute method signature is the same for both implementations,\n// so you can easily switch from one to another\ntry {\n  const res = await pool.execute()\n  console.info(res)\n} catch (err) {\n  console.error(err)\n}\n```\n\nRemember that workers can only send and receive structured-cloneable data.\n\n## Deno and Bun versions\n\n- Deno versions \u003e= 1.40.x are supported.\n- Bun versions \u003e= 1.x are supported.\n\n## [API](https://github.com/poolifier/poolifier-web-worker/blob/master/docs/api.md)\n\n## [General guidelines](https://github.com/poolifier/poolifier-web-worker/blob/master/docs/general-guidelines.md)\n\n## [Worker choice strategies](https://github.com/poolifier/poolifier-web-worker/blob/master/docs/worker-choice-strategies.md)\n\n## Contribute\n\nChoose your task [here](https://github.com/orgs/poolifier/projects/1), propose\nan idea, a fix, an improvement.\n\nSee\n[CONTRIBUTING](https://github.com/poolifier/poolifier-web-worker/blob/master/CONTRIBUTING.md)\nguidelines.\n\n## Team\n\n**Creator/Owner:**\n\n- [**Alessandro Pio Ardizio**](https://github.com/pioardi)\n\n**Maintainers:**\n\n- [**Jérôme Benoit**](https://github.com/jerome-benoit)\n\n**Contributors:**\n\n- [**Shinigami92**](https://github.com/Shinigami92)\n\n## License\n\n[MIT](./LICENSE)\n","funding_links":["https://opencollective.com/poolifier","https://github.com/sponsors/poolifier"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpoolifier%2Fpoolifier-web-worker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpoolifier%2Fpoolifier-web-worker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpoolifier%2Fpoolifier-web-worker/lists"}