{"id":13448580,"url":"https://github.com/wilk/microjob","last_synced_at":"2025-04-13T01:58:07.897Z","repository":{"id":45796138,"uuid":"146167924","full_name":"wilk/microjob","owner":"wilk","description":"A tiny wrapper for turning Node.js worker threads into easy-to-use routines for heavy CPU loads.","archived":false,"fork":false,"pushed_at":"2023-01-04T13:11:29.000Z","size":2046,"stargazers_count":2020,"open_issues_count":22,"forks_count":47,"subscribers_count":27,"default_branch":"master","last_synced_at":"2025-04-13T01:57:37.296Z","etag":null,"topics":["jobs","multithreading","nodejs","thread","threading"],"latest_commit_sha":null,"homepage":"https://wilk.github.io/microjob/","language":"TypeScript","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/wilk.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":"2018-08-26T09:31:59.000Z","updated_at":"2025-03-06T08:46:13.000Z","dependencies_parsed_at":"2023-02-02T13:31:35.246Z","dependency_job_id":null,"html_url":"https://github.com/wilk/microjob","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wilk%2Fmicrojob","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wilk%2Fmicrojob/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wilk%2Fmicrojob/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wilk%2Fmicrojob/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wilk","download_url":"https://codeload.github.com/wilk/microjob/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248654048,"owners_count":21140235,"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":["jobs","multithreading","nodejs","thread","threading"],"created_at":"2024-07-31T05:01:49.536Z","updated_at":"2025-04-13T01:58:07.861Z","avatar_url":"https://github.com/wilk.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","*.js"],"sub_categories":["Node"],"readme":"# Microjob\n\n[![npm version](https://badge.fury.io/js/microjob.svg)](https://badge.fury.io/js/microjob)\n[![Build Status](https://travis-ci.org/wilk/microjob.svg?branch=master)](https://travis-ci.org/wilk/microjob)\n[![Coverage Status](https://coveralls.io/repos/github/wilk/microjob/badge.svg?branch=feature%2Fcoverage)](https://coveralls.io/github/wilk/microjob?branch=feature%2Fcoverage)\n[![Dependencies](https://img.shields.io/david/wilk/microjob.svg)](https://david-dm.org/wilk/microjob?path=packages/microjob)\n\nA tiny wrapper for turning [Node.js threads](https://nodejs.org/api/worker_threads.html) in easy-to-use routines for CPU-bound.\n\n## Introduction\n\nMicrojob is a tiny wrapper for Node.js threads and is intended to perform heavy CPU loads using anonymous functions.\n\n~~So, Microjob treats Node.js threads as temporary working units: if you need to spawn a long-living thread, then you should use the [default API](https://nodejs.org/api/worker_threads.html).~~\n\nFrom version v0.1.0 microjob uses a **[Worker Pool](GUIDE.md#worker-pool)** 🎉\n\nMicrojob follows the same line of the original Node.js documentation: use it only for CPU-bound jobs and not for I/O-bound purposes.\nQuoting the documentation:\n\n\u003e Workers are useful for performing CPU-intensive JavaScript operations; do not use them for I/O, since Node.js’s built-in mechanisms for performing operations asynchronously already treat it more efficiently than Worker threads can.\n\n**Microjob** can be used with **Node.js 12+** without flag. With **Node.js 10.5+** you need the **--experimental-worker** flag activated, otherwise it won't work.\n\nMore details explained in: **[Microjob: a tiny multithreading library for Node.js](https://medium.com/hackernoon/microjob-a-tiny-multithreading-library-for-node-js-92d0500b07d5)**\n\n## Installation\n\nVia **npm**:\n\n```bash\n$ npm install --save microjob\n```\n\n## Quick Example\n\n```js\n(async () =\u003e {\n  const { job, start, stop } = require(\"microjob\");\n\n  try {\n    // start the worker pool\n    await start();\n\n    // this function will be executed in another thread\n    const res = await job(() =\u003e {\n      let i = 0;\n      for (i = 0; i \u003c 1000000; i++) {\n        // heavy CPU load ...\n      }\n\n      return i;\n    });\n\n    console.log(res); // 1000000\n  } catch (err) {\n    console.error(err);\n  } finally {\n    // shutdown worker pool\n    await stop();\n  }\n})();\n```\n\n## Features\n\n- 🛢️ Worker Pool\n- 🏥 auto self-healing\n- 🙌 easy and simple\n- 🕔 supports both sync and async jobs\n- 🛡️ huge test coverage\n- 📜 well documented\n\n## Documentation\n\nDive deep into the documentation to find more examples: **[Guide](GUIDE.md)**\n\n## Known Issues\n\n- **[sanitize worker context](GUIDE.md#job-context)**\n\n## Known Limitations\n\n- **[serialize worker data](GUIDE.md#job-data)**\n- **[passing runtime context](GUIDE.md#job-context)**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilk%2Fmicrojob","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwilk%2Fmicrojob","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilk%2Fmicrojob/lists"}