{"id":15866258,"url":"https://github.com/kanitsharma/workinator","last_synced_at":"2025-08-21T16:09:56.132Z","repository":{"id":57124788,"uuid":"178679983","full_name":"kanitsharma/workinator","owner":"kanitsharma","description":"Run your CPU intensive functions in a separate thread on the fly","archived":false,"fork":false,"pushed_at":"2019-10-31T11:09:56.000Z","size":258,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-07T15:54:27.961Z","etag":null,"topics":["javascript","multithreading","performance","threads","webworkers"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kanitsharma.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-31T11:38:55.000Z","updated_at":"2024-11-21T18:31:00.000Z","dependencies_parsed_at":"2022-08-31T17:01:22.918Z","dependency_job_id":null,"html_url":"https://github.com/kanitsharma/workinator","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/kanitsharma/workinator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kanitsharma%2Fworkinator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kanitsharma%2Fworkinator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kanitsharma%2Fworkinator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kanitsharma%2Fworkinator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kanitsharma","download_url":"https://codeload.github.com/kanitsharma/workinator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kanitsharma%2Fworkinator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265505556,"owners_count":23778536,"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":["javascript","multithreading","performance","threads","webworkers"],"created_at":"2024-10-05T23:05:21.668Z","updated_at":"2025-07-16T11:15:37.777Z","avatar_url":"https://github.com/kanitsharma.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\" \u003e\u003cimg src=\"docs/logo.png\" width=\"200\"/\u003e\u003c/p\u003e\n\n\u003ch1 align=\"center\"\u003e Workinator\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/prettier/prettier\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/code_style-prettier-ff69b4.svg\" alt=\"prettier\"/\u003e\n  \u003c/a\u003e\n\u003ca href=\"https://github.com/rajatsharma/enginite\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/enginite-generator-orange.svg\" alt=\"enginite\"/\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://packagephobia.now.sh/result?p=@kimera/workinator\"\u003e\n  \u003cimg src=\"https://packagephobia.now.sh/badge?p=@kimera/workinator\" alt=\"workinator\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003e Run your CPU intensive functions in a separate thread on the fly, and keep your application running at 60FPS.\n\n- Works on both Browser or Nodejs\n- Minimal API\n- Tiny package, ~1KB gzipped\n- Supports both synchronous or asynchronous code.\n- Automatically cleans up memory after worker thread is finished executing.\n\n## Getting Started\n\n```javascript\n  yarn add @kimera/workinator\n  // or\n  npm i @kimera/workinator\n```\n\n## How it works\n\n### Basic\n```javascript\nimport workinator from '@kimera/workinator';\n\nworkinator(() =\u003e {\n  console.log('Hello from worker');\n})\n\n// Thats it!.\n```\n\n### Synchronous\n```javascript\nimport workinator from '@kimera/workinator';\n\nconst work = () =\u003e {\n  // blocking thread for 2 secs\n  const start = new Date().getTime();\n  while (new Date().getTime() \u003c start + 2000) {}\n\n  return 'Work finished';\n};\n\nconst main = async () =\u003e {\n  const status = await workinator(work);\n  console.log(status);\n};\n\nmain();\n```\n\n## Async with promises\n\n```javascript\nimport workinator from '@kimera/workinator';\n\nworkinator(\n  () =\u003e\n    new Promise(resolve =\u003e {\n      setTimeout(() =\u003e {\n        resolve('Work Finished');\n      }, 2000);\n    }),\n).then(console.log);\n\n// or\n\nconst sleep = ms =\u003e new Promise(resolve =\u003e setTimeout(resolve, ms));\n\nworkinator(async () =\u003e {\n  await sleep(2000);\n  return 'Work Finished';\n}).then(console.log);\n```\n\n## Using Dependencies\n\nWorker functions inside workerinator does not allow using closures, since its executed inside a different thread. So, instead what we can do is inject these dependencies as the second argument of workerinator and you will receive the dependencies as arguments inside worker function in their respective order.\n\n### Example\n\n```javascript\nimport workinator from '@kimera/workinator';\n\nconst log = x =\u003e console.log(x);\n\nworkinator(\n  logger =\u003e\n    new Promise(resolve =\u003e {\n      logger('Dependency working');\n    }),\n  log,\n)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkanitsharma%2Fworkinator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkanitsharma%2Fworkinator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkanitsharma%2Fworkinator/lists"}