{"_id":"@awmottaz/promise-some","name":"@awmottaz/promise-some","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@awmottaz/promise-some","version":"1.0.0","description":"Like Promise.all, but only as many as you've got time for","main":"index.js","type":"module","types":"index.d.ts","scripts":{"compile-and-test":"npm-run-all compile --parallel compile-watch test-watch","compile-watch":"tsc --watch","compile":"tsc","fmt":"prettier --write .","prepublishOnly":"run-s compile fmt test","test-watch":"ava --watch","test":"ava"},"repository":{"type":"git","url":"git+https://github.com/awmottaz/promise-some.git"},"keywords":["JavaScript","TypeScript","Promise"],"author":{"name":"Tony Mottaz","email":"mail@tonymottaz.com"},"license":"MIT","bugs":{"url":"https://github.com/awmottaz/promise-some/issues"},"homepage":"https://github.com/awmottaz/promise-some#readme","devDependencies":{"ava":"^4.3.0","npm-run-all":"^4.1.5","prettier":"2.7.1","typescript":"^4.7.4"},"gitHead":"57fc6b3014091af554070dcf803b60417b6e056b","_id":"@awmottaz/promise-some@1.0.0","_nodeVersion":"16.14.1","_npmVersion":"8.5.0","dist":{"integrity":"sha512-OfJUyMwhsJM9cI8JmmoZQTI0O1YXZgRL3+JvQEwg/WbaKfZF0S3O2J2WMr4BnfhPTYKE1TO0BzX5kWxIlqSCvA==","shasum":"52f3adfcc0fc25226fd3cfa1670e64bd7093d34f","tarball":"https://registry.npmjs.org/@awmottaz/promise-some/-/promise-some-1.0.0.tgz","fileCount":5,"unpackedSize":7624,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIC1jFNbLHxTPBd+SGpwanlKL3RqWcsDN6JUe9V6gBKraAiEAgJnocyVT6OjUtaBz11RgkMmYoQtcCBnZErjBGwiUPjA="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJivjLOACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmq2MRAAlZ1NCzSg1QS2izniCxPh80R+dVjfYE/j7PRPNPzSjCQ2y5VX\r\noOAwcidByu+6r0aRBSgp1X6rOFJ3KzClJdgR3OTHgm6DrH2HsdTsRuSnwJrC\r\nMeqp1fGyEftWAsU/pjrHST7rg1p3eIZiGICTVA67EWpmipzOb0DLg/kJImyi\r\nWQ9YbkQXQYAbuVZeLUNaYrsJpe804KfKF0ZvaiZk3IJVm7ZIyYdvhCYUG6/e\r\nhOxSPV90JwXhAEMyKSGVi04A3x4xLkm15WEBjGMsn+WFWV8sHniHCTEQOy2W\r\nIhPdrdIFH9ogWtzQB0bUccjeq7xrTVqJCsq6SznylmjArZ7L2iJfGvFWEInZ\r\nCXHKiPrO4u/Tr/7oOcbaA+UP7Otz68yrDHSPc/IE8ad86jwGF6/pYgSLK7Bk\r\n9NPnmfyPcVMEV4wX5v2QYAoT7JoOANsiiVI3nGA/qe3Me/CT0WZEtQAdH+qf\r\n/mDDlnSVsphDueok6Ige61ILmOMA9nnxO402tu4vIbrm401dk7oDUWmAKsNX\r\nAmRAVfwjjYKYXHhJgUnhCfA/KNRqapmu1cMTv9tjugUw5wV/4foX7Ka2Yhb5\r\nUpAcfFmFWcTmneX6M4cWIIrvF2/kNoCkuAS0xMp1C8md3HvYdDW9IcLm3fS3\r\nU01mBZ+48kTQ5XAGijST5LKRNjUMwrpzDuU=\r\n=9YP4\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"awmottaz","email":"mail@tonymottaz.com"},"directories":{},"maintainers":[{"name":"awmottaz","email":"mail@tonymottaz.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/promise-some_1.0.0_1656632014207_0.7371429047317817"},"_hasShrinkwrap":false}},"time":{"created":"2022-06-30T23:33:34.148Z","1.0.0":"2022-06-30T23:33:34.351Z","modified":"2022-06-30T23:33:34.470Z"},"maintainers":[{"name":"awmottaz","email":"mail@tonymottaz.com"}],"description":"Like Promise.all, but only as many as you've got time for","homepage":"https://github.com/awmottaz/promise-some#readme","keywords":["JavaScript","TypeScript","Promise"],"repository":{"type":"git","url":"git+https://github.com/awmottaz/promise-some.git"},"author":{"name":"Tony Mottaz","email":"mail@tonymottaz.com"},"bugs":{"url":"https://github.com/awmottaz/promise-some/issues"},"license":"MIT","readme":"The `PromiseSome` utility allows you to race a list of promises against one \"signal\" promise. If any of your promises resolve before the signal resolves, then you will receive that data. The rest remain `undefined`.\n\n## Quick start\n\nUsing `PromiseSome` is similar to using `Promise.all`, except that you add a second argument for the \"signal\" promise. `PromiseSome` will resolve in one of the following scenarios:\n\n- Every promise in the array resolves before the signal promise resolves. Then the `results` array is the same as if you just ran `Promise.all`.\n- The `signal` promise resolves before all of the other promises have resolved. Then the `results` array is a sparse array containing the results of those promises that did resolve before the `signal` resolved.\n\n```js\nimport PromiseSome from \"@awmottaz/promise-some\";\n\nasync function fetchSomeData() {\n  // Only wait 500ms for the fetches to resolve.\n  const signal = new Promise((resolve) => {\n    setTimeout(resolve, 500);\n  });\n\n  // The `results` array is populated with the results of\n  // all of the promises that were able to resolve before\n  // the `signal` promise resolved, in the same order of\n  //\n  const {\n    results: [fooData, barData, bazData],\n  } = PromiseSome([fetchFoo, fetchBar, fetchBaz], signal);\n\n  return {\n    fooData,\n    barData,\n    bazData,\n  };\n}\n```\n\nSee the `examples` folder with more examples. You can run these yourself with `node`!\n\n## API and documentation\n\n- See `index.d.ts` for the API of `PromiseSome`.\n- See the `examples` folder for examples of `PromiseSome` in action.\n- See `test.js` for more nuanced usage and test cases.\n\n## Support and bug reporting\n\n- [View already reported issues](https://github.com/awmottaz/promise-some/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc)\n- [Create a new issue](https://github.com/awmottaz/promise-some/issues/new/choose)\n\n## Developing\n\nTo setup your local environment, clone this repo and run `npm install`.\n\nTo compile the code and run tests in watch mode, run `npm run compile-and-test`.\n\nTo compile the TypeScript source into `.js` and `.d.ts` files, run `npm run compile`, or `npm run compile-watch` to compile in watch mode.\n\nTo run the tests, run `npm run test`,or `npm run test-watch` to run in watch mode. Note that tests run against the **compiled** output (`index.js`), _not_ the TypeScript source. The `compile-and-test` script handles this for you, but the `test` and `test-watch` scripts do not.\n\n## Contributing\n\nThanks for your interest in contributing to this repository!\n\nThe steps for contributing are:\n\n1. Fork this repository.\n2. Follow the [Developing](#developing) section above.\n3. Make your changes in the fork.\n4. Add or update tests as needed to cover the change.\n5. Update the [CHANGELOG](./CHANGELOG.md) file with your changes.\n6. Run `npm run compile` to update the compiled output.\n7. Run `npm run fmt` to format all source files.\n8. Commit your changes.\n9. Open a Pull Request.\n\n### Commit message style\n\nCommit messages are for maintainers of this package, _not_ end users. If the change does affect the end users, then you should include a note of the change in the [CHANGELOG](./CHANGELOG.md) as part of the commit.\n\nKeep commits atomic, and be sure to include plenty of context for the change as needed.\n\nThe first line of the commit should answer the question, \"What changes if I apply this commit?\".\n\nThe body of the commit message can be used to add context, nuance, and color to the first line summary.\n\nIf this commit resolves an issue, include the issue number in the footer of the commit message by writing, `Closes #123`.\n","readmeFilename":"README.md"}