{"id":13816808,"url":"https://github.com/zakodium/ework","last_synced_at":"2026-01-18T04:36:14.856Z","repository":{"id":57231552,"uuid":"193059229","full_name":"zakodium/ework","owner":"zakodium","description":"Ework","archived":false,"fork":false,"pushed_at":"2019-12-20T11:09:07.000Z","size":285,"stargazers_count":18,"open_issues_count":3,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-24T02:51:09.486Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/zakodium.png","metadata":{"files":{"readme":"README.md","changelog":"History.md","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":"2019-06-21T08:15:29.000Z","updated_at":"2024-04-26T09:00:11.000Z","dependencies_parsed_at":"2022-09-04T17:31:41.615Z","dependency_job_id":null,"html_url":"https://github.com/zakodium/ework","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/zakodium/ework","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zakodium%2Fework","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zakodium%2Fework/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zakodium%2Fework/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zakodium%2Fework/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zakodium","download_url":"https://codeload.github.com/zakodium/ework/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zakodium%2Fework/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28529859,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T00:39:45.795Z","status":"online","status_checked_at":"2026-01-18T02:00:07.578Z","response_time":98,"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-08-04T06:00:21.901Z","updated_at":"2026-01-18T04:36:14.840Z","avatar_url":"https://github.com/zakodium.png","language":"TypeScript","readme":"# ework\n\n[![NPM version][npm-image]][npm-url]\n[![build status][ci-image]][ci-url]\n[![npm download][download-image]][download-url]\n\nEwork.\n\nExecute your tasks on another thread or in parallel, with a simple to use and\ncross-platform (Node.js \u003e=10 and modern browsers) API.\n\n## Installation\n\n`$ npm i ework`\n\n## Usage\n\n```js\nimport { Ework } from 'ework';\n\nasync function run() {\n  const worker = new Ework((value) =\u003e value ** 2);\n  const value = await worker.execute(6); // 36\n  const values = await worker.map([1, 2, 3]); // [1, 4, 9]\n  await worker.terminate();\n}\n\nrun().catch((e) =\u003e {\n  console.error(e);\n  process.exit(1);\n});\n```\n\n## API\n\n### `new Ework(executor[, options])`\n\n#### `executor`\n\nMust be a function or async function. It will receive the argument passed to\n`execute()`. The code of this function will be passed to the worker, but not\nits context, so it shouldn't use variables from its surrounding scope.\n\n#### `options`\n\nAn object with the following optional properties:\n\n- `init`: Function  \n  Initialization function that will be executed after spawning the worker and\n  before sending jobs to it. If the function returns a Promise, it will be awaited.\n- `initData`: any  \n  Optional data passed to the init function of each spawned worker.\n- `numWorkers`: number  \n  Number of workers to spawn. If this option is specified, `maxWorkers` and\n  `minFreeThreds` will be ignored.\n- `maxWorkers`: number (Default: number of logical CPUs)  \n  Maximum number of workers that will be spawned. This number must be at least\n  one and is only taken into account if smaller than the total number of CPUs.\n- `minFreeThreads`: number (Default: 1)  \n  Minimum number of CPU threads that will be kept free.\n  Along with `maxWorkers`, this will determine the number of workers that will\n  be spawned. If there is only one CPU, this option is ignored and one worker\n  will be spawned.\n\n### `Ework#execute(value)`\n\nRun the executor on one of the free workers with the passed value. Returns a\nPromise that will be resolved with the value returned from the executor. If no\nworker is free, the call is added to a FIFO queue.\n\n### `Ework#map(iterable)`\n\nSend each value of the iterable to the executor. Once every value was processed,\nresolves with an array of results.\n\n### `Ework#terminate`\n\nTerminate all the spawned workers. This must be called to cleanup if the ework\ninstance won't be used anymore.\n\n## License\n\n[MIT](./LICENSE)\n\n[npm-image]: https://img.shields.io/npm/v/ework.svg\n[npm-url]: https://www.npmjs.com/package/ework\n[ci-image]: https://github.com/zakodium/ework/workflows/Node.js%20CI/badge.svg?branch=master\n[ci-url]: https://github.com/zakodium/ework/actions?query=workflow%3A%22Node.js+CI%22\n[download-image]: https://img.shields.io/npm/dm/ework.svg\n[download-url]: https://www.npmjs.com/package/ework\n","funding_links":[],"categories":["Packages"],"sub_categories":["Others"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzakodium%2Fework","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzakodium%2Fework","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzakodium%2Fework/lists"}