{"id":18563192,"url":"https://github.com/compulim/promise-race-map","last_synced_at":"2025-05-15T18:12:52.352Z","repository":{"id":33506880,"uuid":"158991012","full_name":"compulim/promise-race-map","owner":"compulim","description":"Promise.race implementation to works with a JavaScript map","archived":false,"fork":false,"pushed_at":"2022-12-08T06:16:41.000Z","size":1204,"stargazers_count":2,"open_issues_count":12,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-19T19:22:53.674Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/compulim.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}},"created_at":"2018-11-25T02:29:50.000Z","updated_at":"2020-05-26T09:41:25.000Z","dependencies_parsed_at":"2023-01-15T01:13:01.664Z","dependency_job_id":null,"html_url":"https://github.com/compulim/promise-race-map","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compulim%2Fpromise-race-map","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compulim%2Fpromise-race-map/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compulim%2Fpromise-race-map/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/compulim%2Fpromise-race-map/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/compulim","download_url":"https://codeload.github.com/compulim/promise-race-map/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254394726,"owners_count":22063984,"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":"2024-11-06T22:12:03.669Z","updated_at":"2025-05-15T18:12:49.816Z","avatar_url":"https://github.com/compulim.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# promise-race-map\n\nA [`Promise.race`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/race) implementation that works with JavaScript map.\n\n[![npm version](https://badge.fury.io/js/promise-race-map.svg)](https://badge.fury.io/js/promise-race-map) [![Build Status](https://travis-ci.org/compulim/promise-race-map.svg?branch=master)](https://travis-ci.org/compulim/promise-race-map) [![Coverage Status](https://coveralls.io/repos/github/compulim/promise-race-map/badge.svg)](https://coveralls.io/github/compulim/promise-race-map)\n\n## Background\n\n[`Promise.race`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/race) is useful when you need either one of the Promise to complete before proceeding. But if you need to process the result, it isn't easy to distinguish between two promises.\n\n### Before using `promise-race-map`\n\nBefore using this package, you will need to write code like this.\n\n```js\nconst p1 = fn1();\nconst p2 = fn2();\n\n// Given both Promise do not return falsy values\nconst { r1, r2 } = await Promise.race([\n  () =\u003e p1.then(res =\u003e ({ r1: res })),\n  () =\u003e p2.then(res =\u003e ({ r2: res }))\n]);\n\nif (r1) {\n  // Process result from fn1()\n} else {\n  // Process result from fn2()\n}\n```\n\n### After using `promise-race-map`\n\nAfter using this package, you can write shorter and more readable code like this.\n\n```js\nconst { r1, r2 } = await Promise.race({\n  r1: fn1(),\n  r2: fn2()\n});\n\nif (r1) {\n  // Process result from fn1()\n} else {\n  // Process result from fn2()\n}\n```\n\n# Contributions\n\nLike us? [Star](https://github.com/compulim/promise-race-map/stargazers) us.\n\nWant to make it better? [File](https://github.com/compulim/promise-race-map/issues) us an issue.\n\nDon't like something you see? [Submit](https://github.com/compulim/promise-race-map/pulls) a pull request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcompulim%2Fpromise-race-map","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcompulim%2Fpromise-race-map","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcompulim%2Fpromise-race-map/lists"}