{"id":20470582,"url":"https://github.com/ramchaik/batch-promise","last_synced_at":"2025-06-21T16:35:43.497Z","repository":{"id":100091330,"uuid":"384215668","full_name":"ramchaik/batch-promise","owner":"ramchaik","description":"Effortlessly Manage Promise Execution in JavaScript","archived":false,"fork":false,"pushed_at":"2024-06-16T01:20:51.000Z","size":1627,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-05T13:34:16.418Z","etag":null,"topics":["batching","npm-package","parallelism","promise","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/ramchaik.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"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}},"created_at":"2021-07-08T18:28:44.000Z","updated_at":"2024-06-16T01:20:54.000Z","dependencies_parsed_at":"2024-06-16T02:24:43.849Z","dependency_job_id":"fa8ef154-1200-4fa1-acbf-f24f8c45c6ae","html_url":"https://github.com/ramchaik/batch-promise","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/ramchaik/batch-promise","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramchaik%2Fbatch-promise","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramchaik%2Fbatch-promise/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramchaik%2Fbatch-promise/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramchaik%2Fbatch-promise/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ramchaik","download_url":"https://codeload.github.com/ramchaik/batch-promise/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ramchaik%2Fbatch-promise/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261159380,"owners_count":23118002,"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":["batching","npm-package","parallelism","promise","typescript"],"created_at":"2024-11-15T14:13:31.056Z","updated_at":"2025-06-21T16:35:38.477Z","avatar_url":"https://github.com/ramchaik.png","language":"TypeScript","readme":"# Batch Promises \nA simple solution to batch promises\n\n## Why?\n\nWhile working on my project, I encountered a significant roadblock: the lack of a robust solution for batching promises effectively. This inspired me to create batch-promises, a solution that not only fills this gap but also simplifies asynchronous code management.\n\nBy adopting batch-promises, you gain the ability to:\n1. **Optimize Performance**: Execute promises strategically, reducing unnecessary resource usage and potential bottlenecks.\n2. **Improve Code Readability**: Benefit from clear async/await integration, making your asynchronous logic easier to understand and maintain.\n3. **Error Handling Made Easy**: Employ the structured [successResults, errorResults] return value to gracefully handle both successful and failed promises.\n\n## Key Features:\n1. **Enhanced Control and Efficiency**: Execute promises in well-defined batches, optimizing resource utilization and preventing application overload.\n2. **Simplified Async/Await Syntax**: Enjoy intuitive async/await support for cleaner and more readable asynchronous operations.\n3. **Clear Error Handling**: The batchPromises function returns a two-element array: [successResults, errorResults], providing a structured approach to handling both successful and rejected promises.\n\n\n## Installation\n\n```sh\nnpm i @vsr.common/batch-promises\n```\n\n## 🚀 Usage\n\n### Async/await way\n```javascript\nimport { batchPromises } from '@vsr.common/batch-promises';\n\nconst arr = [1, 2, 3, 4, 5];\nconst batchSize = 2;\nconst [success, error] = await batchPromises(batchSize, arr, (ele) =\u003e\n  Promise.resolve(ele)\n);\n```\n\n### Promise way\n```javascript\nconst { batchPromises } = require('@vsr.common/batch-promises');\n\nconst arr = [1, 2, 3, 4, 5];\nconst batchSize = 2;\nbatchPromises(batchSize, arr, (ele) =\u003e\n  Promise.resolve(ele)\n).then(([success, error]) =\u003e {\n  // do your thing!\n});\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Framchaik%2Fbatch-promise","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Framchaik%2Fbatch-promise","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Framchaik%2Fbatch-promise/lists"}