{"id":15395019,"url":"https://github.com/goto-bus-stop/p-wait-all","last_synced_at":"2025-04-16T00:03:18.179Z","repository":{"id":52433184,"uuid":"120437882","full_name":"goto-bus-stop/p-wait-all","owner":"goto-bus-stop","description":"`Promise.all`, but it waits for all promises to settle even if one of them rejected","archived":false,"fork":false,"pushed_at":"2021-04-29T11:19:21.000Z","size":9,"stargazers_count":15,"open_issues_count":0,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T03:06:20.529Z","etag":null,"topics":["async-await","async-functions","await","promise","promises"],"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/goto-bus-stop.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}},"created_at":"2018-02-06T10:21:14.000Z","updated_at":"2023-06-10T06:34:45.000Z","dependencies_parsed_at":"2022-08-25T21:11:54.329Z","dependency_job_id":null,"html_url":"https://github.com/goto-bus-stop/p-wait-all","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/goto-bus-stop%2Fp-wait-all","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goto-bus-stop%2Fp-wait-all/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goto-bus-stop%2Fp-wait-all/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goto-bus-stop%2Fp-wait-all/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/goto-bus-stop","download_url":"https://codeload.github.com/goto-bus-stop/p-wait-all/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249173071,"owners_count":21224483,"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":["async-await","async-functions","await","promise","promises"],"created_at":"2024-10-01T15:25:23.107Z","updated_at":"2025-04-16T00:03:18.154Z","avatar_url":"https://github.com/goto-bus-stop.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# p-wait-all\n\n`Promise.all`, but it waits for all promises to settle even if one of them rejected.\n\n## Installation\n\nWith npm:\n\n```bash\nnpm install --save p-wait-all\n```\n\n## Usage\n\n```js\nvar waitAll = require('p-wait-all')\n\nvar settled = false\nvar result = waitAll([\n  Promise.reject(new Error('operation failed')),\n  delay(200).then(function () { settled = true })\n])\n\nresult.catch(function (err) {\n  // rejected after 200ms;\n  // settled === true\n})\n```\n\nCompare doing this with `Promise.all`:\n\n```js\nvar settled = false\nvar result = Promise.all([\n  Promise.reject(new Error('operation failed')),\n  delay(200).then(function () { settled = true })\n])\n\nresult.catch(function (err) {\n  // rejected immediately;\n  // settled === false\n})\n```\n\nThis behaviour is useful if you are doing two async operations that may fail individually, so that both operations need to be rolled back.\n\nFor example, saving two related mongoose models, where one may fail (eg. from duplicate key errors):\n\n```js\nwaitAll([\n  model1.save(),\n  relatedModel.save()\n]).catch(function (err) {\n  var p = []\n  if (!model1.isNew) p.push(model1.remove())\n  if (!relatedModel.isNew) p.push(relatedModel.remove())\n  return Promise.all(p)\n})\n```\n\nYou cannot remove a model if it is still in the process of being saved, so you have to wait for all the `save()` promises to resolve before attempting to roll them back.\n\n## API\n\n### result = require('p-wait-all')(promises)\n\nWait for `promises` to settle. If any of them errored, reject the `result` promise with the error. If all of them resolved, resolve `result` with an array of resolution values, in order.\n\n## License\n\n[MIT](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoto-bus-stop%2Fp-wait-all","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoto-bus-stop%2Fp-wait-all","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoto-bus-stop%2Fp-wait-all/lists"}