{"id":34618112,"url":"https://github.com/lbfalvy/buffered-dispatch","last_synced_at":"2026-05-26T01:04:01.217Z","repository":{"id":57191029,"uuid":"466888799","full_name":"lbfalvy/buffered-dispatch","owner":"lbfalvy","description":"Buffer function calls and dispatch them on servers as they become available","archived":false,"fork":false,"pushed_at":"2023-02-08T18:40:55.000Z","size":109,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-28T06:28:28.983Z","etag":null,"topics":["command-pattern","load-balancing"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/buffered-dispatch","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/lbfalvy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-03-07T00:08:26.000Z","updated_at":"2022-08-28T23:46:41.000Z","dependencies_parsed_at":"2022-09-15T22:21:54.116Z","dependency_job_id":null,"html_url":"https://github.com/lbfalvy/buffered-dispatch","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/lbfalvy/buffered-dispatch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lbfalvy%2Fbuffered-dispatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lbfalvy%2Fbuffered-dispatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lbfalvy%2Fbuffered-dispatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lbfalvy%2Fbuffered-dispatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lbfalvy","download_url":"https://codeload.github.com/lbfalvy/buffered-dispatch/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lbfalvy%2Fbuffered-dispatch/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33499282,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-25T14:31:05.219Z","status":"ssl_error","status_checked_at":"2026-05-25T14:31:02.878Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["command-pattern","load-balancing"],"created_at":"2025-12-24T14:54:54.083Z","updated_at":"2026-05-26T01:04:01.209Z","avatar_url":"https://github.com/lbfalvy.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Buffered Dispatch\n\nBuffer function calls and dispatch them on servers as they become available\n\nThink of a load balancer balancing a cluster of HTTP servers. It accepts\nrequests, dispatches them on the first available server, then\nforward the response back to the client. This utility is a lot like that,\nexcept it doesn't keep track of responses and servers signal when they're\nready to accept the next request explicitly\n\n## Usage\n\nHere we have constructed a buffered dispatch with two number arguments\nand a number return value, representing a division operation.\n\n```ts\nimport { bufferedDispatch } from 'buffered-dispatch'\nconst [requestDiv, serveDiv] = bufferedDispatch\u003c[number, number], number\u003e()\n```\n\nThis would go in something like a HTTP request handler, an asynchronous\nfunction that represents a client. Any number of clients can call\n`request` concurrently\n\n```ts\nconst result = await requestDiv(3, 5)\n```\n\nThis is a grossly oversimplified server. Any number of servers can call\n`serve` concurrently, they will be resolved as clients arrive. Once a\nserver and a client have been matched the dispatcher forgets about both\nof them\n\n```ts\nwhile (true) {\n\tconst { resolve, reject, args: [num, denom] } = await serveDiv()\n\tif (denom == 0) reject(new Error('Division by zero'))\n\telse resolve(num / denom)\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flbfalvy%2Fbuffered-dispatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flbfalvy%2Fbuffered-dispatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flbfalvy%2Fbuffered-dispatch/lists"}