{"id":18048518,"url":"https://github.com/bent10/batch-me-up","last_synced_at":"2026-02-08T06:35:31.776Z","repository":{"id":235125221,"uuid":"790055614","full_name":"bent10/batch-me-up","owner":"bent10","description":"Efficient batch processing for node.js and browsers","archived":false,"fork":false,"pushed_at":"2025-01-05T07:01:17.000Z","size":140,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-27T18:50:24.747Z","etag":null,"topics":["api","batch","batching","cpu","data-processing","optimization","parallelization"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/batch-me-up","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/bent10.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}},"created_at":"2024-04-22T07:24:07.000Z","updated_at":"2024-10-30T12:03:32.000Z","dependencies_parsed_at":"2024-05-14T13:29:13.008Z","dependency_job_id":"586cfa51-92b7-4865-af34-2495b2bbc87d","html_url":"https://github.com/bent10/batch-me-up","commit_stats":{"total_commits":9,"total_committers":3,"mean_commits":3.0,"dds":0.4444444444444444,"last_synced_commit":"753689b1279bc198306b663f6534faed002fbbe3"},"previous_names":["bent10/batch-me-up"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bent10%2Fbatch-me-up","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bent10%2Fbatch-me-up/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bent10%2Fbatch-me-up/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bent10%2Fbatch-me-up/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bent10","download_url":"https://codeload.github.com/bent10/batch-me-up/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248197931,"owners_count":21063623,"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":["api","batch","batching","cpu","data-processing","optimization","parallelization"],"created_at":"2024-10-30T20:13:15.339Z","updated_at":"2026-02-08T06:35:31.731Z","avatar_url":"https://github.com/bent10.png","language":"TypeScript","readme":"# batch-me-up\n\nA utility for efficiently splitting data into batches based on available CPU resources.\n\n## Why?\n\n- **Automatic Batch Sizing:** Optimizes batch size based on the number of available CPUs for efficient processing.\n- **Custom Batch Sizes:** Allows us to specify batch sizes for specific needs.\n- **Flexibility:** Works with arrays of any data type.\n\n## Install\n\n```bash\nnpm install batch-me-up\n```\n\nOr yarn:\n\n```bash\nyarn add batch-me-up\n```\n\nAlternatively, you can also include this module directly in your HTML file from CDN:\n\n```yml\nUMD: https://cdn.jsdelivr.net/npm/batch-me-up/dist/index.umd.js\nESM: https://cdn.jsdelivr.net/npm/batch-me-up/+esm\nCJS: https://cdn.jsdelivr.net/npm/batch-me-up/dist/index.cjs\n```\n\n## Usage\n\n```js\nimport generateBatches from 'batch-me-up'\n\nconst data = [1, 2, 3, 4, 5, 6, 7, 8]\n\n// determine batch size based on available CPUs\nconst batches = await generateBatches(data)\n\n// or specify a custom batch size\nconst batchesWithCustomSize = await generateBatches(data, 2)\n\n// process each batch\nconst results = await Promise.all(\n  batches.map(async batch =\u003e {\n    // process each item within the batch concurrently\n    return await Promise.all(batch.map(processItem))\n  })\n)\n\n// flatten the results array, if needed\nconst finalResults = results.flat()\nconsole.log(finalResults) // Output: [2, 4, 6, 8, 10, 12, 14, 16]\n```\n\n## API\n\n### `generateBatches\u003cT = any\u003e(data: T[], batchSize?: number): Promise\u003cT[][]\u003e`\n\nGenerates batches of data based on the number of CPUs available or a provided batch size.\n\n- `data` (array): The array of data to be batched.\n- `batchSize` (number, optional): The desired size of each batch. If not provided, the function automatically determines the optimal batch size based on available CPUs.\n\n**Returns:** An array of arrays, where each sub-array represents a batch of the original data.\n\n## Use cases\n\n- **Parallel Processing:** Divide a large dataset into batches for parallel processing using libraries like `Promise.all` or worker threads.\n- **Streaming Data:** Process data in chunks as it is received from a stream or API.\n- **Machine Learning:** Batch training data for efficient model training.\n\n## Contributing\n\nWe 💛\u0026nbsp; issues.\n\nWhen committing, please conform to [the semantic-release commit standards](https://www.conventionalcommits.org/). Please install `commitizen` and the adapter globally, if you have not already.\n\n```bash\nnpm i -g commitizen cz-conventional-changelog\n```\n\nNow you can use `git cz` or just `cz` instead of `git commit` when committing. You can also use `git-cz`, which is an alias for `cz`.\n\n```bash\ngit add . \u0026\u0026 git cz\n```\n\n## License\n\n![GitHub](https://img.shields.io/github/license/bent10/batch-me-up)\n\nA project by [Stilearning](https://stilearning.com) \u0026copy; 2021-2024.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbent10%2Fbatch-me-up","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbent10%2Fbatch-me-up","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbent10%2Fbatch-me-up/lists"}