{"id":13802525,"url":"https://github.com/ide/mux","last_synced_at":"2025-04-05T10:10:24.882Z","repository":{"id":26808941,"uuid":"30267451","full_name":"ide/mux","owner":"ide","description":" Creates a promise that waits for the promises in nested data structures and resolves to data structures of the same form. It recursively traverses the input data structure and multiplexes its promises.","archived":false,"fork":false,"pushed_at":"2024-06-18T21:26:25.000Z","size":284,"stargazers_count":156,"open_issues_count":1,"forks_count":9,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T09:12:16.609Z","etag":null,"topics":["promise"],"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/ide.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":"2015-02-03T22:13:43.000Z","updated_at":"2024-07-01T19:26:53.000Z","dependencies_parsed_at":"2024-01-13T10:42:21.103Z","dependency_job_id":"d546b095-a1b2-45e7-889f-f797c14e85d8","html_url":"https://github.com/ide/mux","commit_stats":{"total_commits":48,"total_committers":4,"mean_commits":12.0,"dds":0.5208333333333333,"last_synced_commit":"5c4df13638633ddc96e715fb82a310585d1dc41e"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ide%2Fmux","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ide%2Fmux/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ide%2Fmux/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ide%2Fmux/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ide","download_url":"https://codeload.github.com/ide/mux/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247318745,"owners_count":20919484,"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":["promise"],"created_at":"2024-08-04T00:01:46.534Z","updated_at":"2025-04-05T10:10:24.858Z","avatar_url":"https://github.com/ide.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mux [![Tests](https://github.com/ide/mux/workflows/Tests/badge.svg)](https://github.com/ide/mux/actions?query=workflow%3ATests) [![codecov](https://codecov.io/gh/ide/mux/branch/master/graph/badge.svg)](https://codecov.io/gh/ide/mux)\nA simple and convenient function that resolves promises in data structures like arrays, objects, Maps, and Sets\n\n## What is mux?\n\nMux is a function that multiplexes promises in nested data structures and resolves them like this:\n\n```js\nawait mux({\n  a: asyncFunction1(),\n  b: asyncFunction2(),\n});\n\n// Result:\n{\n  a: result1,\n  b: result2,\n}\n```\n\n## Installing mux\n\n```sh\nyarn add @expo/mux\n```\n\nAnd import it like this:\n\n```js\nimport mux from '@expo/mux';\n```\n\n## More examples\n\nYou can also pass in deeply nested data structures like this:\n\n```js\nawait mux({\n  a: {\n    b: asyncFunction1(),\n  },\n});\n\n// Result:\n{\n  a: {\n    b: result1,\n  },\n}\n```\n\nMux supports several standard JavaScript data structures:\n\n```js\nawait mux(new Set([\n  asyncFunction1(),\n  asyncFunction2(),\n]));\n\n// Result:\nnew Set([\n  result1,\n  result2,\n])\n```\n\nAnd if your promises themselves result in data structures, mux will recurse into them and resolve the nested promises.\n\n```js\nawait mux([\n  Promise.resolve({\n    a: asyncFunction1(),\n  }),\n]);\n\n// Result:\n[\n  {\n    a: result1,\n  },\n]\n```\n\nCheck out [the test suite](src/__tests__/mux-tests.js) for even more examples.\n\n## Interesting use cases\n\nIf you've discovered a particularly interesting way to use mux, add it here and send a PR to share it.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fide%2Fmux","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fide%2Fmux","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fide%2Fmux/lists"}