{"id":19714387,"url":"https://github.com/peternaydenov/batch-runner","last_synced_at":"2025-04-29T19:32:52.166Z","repository":{"id":208027094,"uuid":"720650650","full_name":"PeterNaydenov/batch-runner","owner":"PeterNaydenov","description":"Execute a batch job with a simple call","archived":false,"fork":false,"pushed_at":"2025-04-20T09:38:10.000Z","size":598,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-20T10:40:24.607Z","etag":null,"topics":["batch","execute","job","runner"],"latest_commit_sha":null,"homepage":"","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/PeterNaydenov.png","metadata":{"files":{"readme":"README.md","changelog":"Changelog.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-11-19T06:15:09.000Z","updated_at":"2025-04-20T09:38:13.000Z","dependencies_parsed_at":"2023-11-19T08:20:58.604Z","dependency_job_id":"500aa236-5a72-47dd-8e1d-aee3926e7af5","html_url":"https://github.com/PeterNaydenov/batch-runner","commit_stats":null,"previous_names":["peternaydenov/batch-runner"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PeterNaydenov%2Fbatch-runner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PeterNaydenov%2Fbatch-runner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PeterNaydenov%2Fbatch-runner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PeterNaydenov%2Fbatch-runner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PeterNaydenov","download_url":"https://codeload.github.com/PeterNaydenov/batch-runner/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251569645,"owners_count":21610596,"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":["batch","execute","job","runner"],"created_at":"2024-11-11T22:31:23.885Z","updated_at":"2025-04-29T19:32:49.248Z","avatar_url":"https://github.com/PeterNaydenov.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Batch Runner (@peter.naydenov/batch-runner)\n\n![version](https://img.shields.io/github/package-json/v/peterNaydenov/batch-runner)\n![GitHub License](https://img.shields.io/github/license/peterNaydenov/batch-runner)\n![GitHub issues](https://img.shields.io/github/issues-raw/peterNaydenov/batch-runner)\n![npm bundle size](https://img.shields.io/bundlephobia/minzip/%40peter.naydenov%2Fbatch-runner)\n\n\n\n## Description\n\nExecute a batch job with a simple call. Batch itself contains a name, source of data and a job to be executed. Batch runner will execute the job for each item in the source.\n\nSource is a function that returns an array of items. Source function will be executed on each job run request so the source can be dynamic. Each item will be passed to the job function.\n\nIn job run request you can provide extra data parameters that will be passed to the job function as well after the item from the source.\n\nLibrary `batch-runner` is a framework agnostic. No dependencies.\n\n\n\n## Installation\nHere is how to install the library:\n```\nnpm i @peter.naydenov/batch-runner\n```\n\n\n\n## Methods\nLibrary has only two methods:\n```js\n  define : 'define a batch'\n, run   : 'run a batch'\n```\n\n\n\n## Definition of Batch\n    \n```js\nbatch.define ( {\n      name   : 'string. Name of the batch'\n    , source : 'function. Should return a source of data for the job'\n    , job    : 'job to be executed'\n```\n\n\n\n## How to use\nSimplified example:\n```js\nimport batchRunner from '@peter.naydenov/batch-runner'\n\nconst batch = batchRunner();\nbatch.define ({\n                      name   : 'myBatch'\n                    , source : () =\u003e [1, 2, 3]\n                    , job    : ({item,i,END},x) =\u003e console.log(item,x)\n            });\n\nbatch.run ( 'myBatch', 'extra') // Extra parameter will be passed to the job function\n// -\u003e 1,extra\n// -\u003e 2,extra\n// -\u003e 3,extra\n// Number of extra parameters is not limited\n```\n\nJob definition first argument is an object `{item,i,END}`, where `item` is the current item, `i` is the current source index, `END` is constant. To stop further function evocation return the `END` constant.\nExample:\n```js\nbatch.define ({\n                      name   : 'myBatch'\n                    , source : () =\u003e [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]\n                    , job    : ({item,i,END},x) =\u003e {\n                                    return ( i \u003c 2 ) ? item : END\n                                  }\n            });\nlet r = batch.run ( 'myBatch' )\n// r -\u003e [1,2]\n```\n\n\n\n\n## Links\n- [History of changes](https://github.com/PeterNaydenov/batch-runner/blob/main/Changelog.md)\n- [Migration Guides](https://github.com/PeterNaydenov/batch-runner/blob/main/Migration.guide.md)\n\n\n\n## Credits\n'@peter.naydenov/batch-runner' was created and supported by Peter Naydenov.\n\n\n\n## License\n'@peter.naydenov/batch-runner' is released under the [MIT License](http://opensource.org/licenses/MIT).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeternaydenov%2Fbatch-runner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeternaydenov%2Fbatch-runner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeternaydenov%2Fbatch-runner/lists"}