{"id":28717258,"url":"https://github.com/edvardchen/batch-dispatch","last_synced_at":"2025-06-15T03:13:58.954Z","repository":{"id":252247309,"uuid":"837120889","full_name":"edvardchen/batch-dispatch","owner":"edvardchen","description":"A small library for async batching process","archived":false,"fork":false,"pushed_at":"2024-08-08T12:52:20.000Z","size":36,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-01T19:03:42.891Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/edvardchen.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-02T08:59:24.000Z","updated_at":"2024-08-08T12:53:09.000Z","dependencies_parsed_at":"2024-08-08T16:17:15.188Z","dependency_job_id":null,"html_url":"https://github.com/edvardchen/batch-dispatch","commit_stats":null,"previous_names":["edvardchen/batch-dispatch"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/edvardchen/batch-dispatch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edvardchen%2Fbatch-dispatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edvardchen%2Fbatch-dispatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edvardchen%2Fbatch-dispatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edvardchen%2Fbatch-dispatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/edvardchen","download_url":"https://codeload.github.com/edvardchen/batch-dispatch/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edvardchen%2Fbatch-dispatch/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259914930,"owners_count":22931334,"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":[],"created_at":"2025-06-15T03:13:53.178Z","updated_at":"2025-06-15T03:13:58.933Z","avatar_url":"https://github.com/edvardchen.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# batch-dispatch\n\nA small toolkit to allow batch-processing scattering async calls. Inspired by GraphQL's DataLoader\n\n## Install\n\n```bash\nnpm i batch-dispatch\n```\n\n## Usage\n\n```js\nimport { batchDispatch } from \"batch-dispatch\";\n\nconst getUserInfoById = batchDispatch(\n  (paramsList) =\u003e {\n    return fetch(url, {\n      method: \"POST\",\n      body: JSON.stringify({\n        list: paramsList.map((params) =\u003e params[0]),\n      }),\n    });\n  },\n  (result, params) =\u003e {\n    return result.list.find((item) =\u003e item.id === params[0]);\n  },\n);\n\ngetUserInfoById(1).then((user) =\u003e {\n  // user.id === 1\n});\n\ngetUserInfoById(2).then((user) =\u003e {\n  // user.id === 2\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedvardchen%2Fbatch-dispatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fedvardchen%2Fbatch-dispatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedvardchen%2Fbatch-dispatch/lists"}