{"name":"p-any","version":"4.0.0","description":"Wait for any promise to be fulfilled","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-any.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":"./index.js","engines":{"node":">=12.20"},"scripts":{"test":"xo && ava && tsd"},"keywords":["promise","any","resolved","wait","collection","iterable","iterator","race","fulfilled","fastest","one","single","async","await","promises","bluebird"],"dependencies":{"p-cancelable":"^3.0.0","p-some":"^6.0.0"},"devDependencies":{"ava":"^3.15.0","delay":"^5.0.0","tsd":"^0.16.0","xo":"^0.40.1"},"gitHead":"a5d02723fcf583010683a2758169feb605e57171","bugs":{"url":"https://github.com/sindresorhus/p-any/issues"},"homepage":"https://github.com/sindresorhus/p-any#readme","_id":"p-any@4.0.0","_nodeVersion":"12.22.1","_npmVersion":"7.10.0","dist":{"integrity":"sha512-S/B50s+pAVe0wmEZHmBs/9yJXeZ5KhHzOsgKzt0hRdgkoR3DxW9ts46fcsWi/r3VnzsnkKS7q4uimze+zjdryw==","shasum":"0e9c8b0fa3e58cc79e6a1c6c715aa9326b6a4447","tarball":"http://registry-npm.ywwl.com/p-any/download/p-any-4.0.0.tgz","fileCount":5,"unpackedSize":5395,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgtQfUCRA9TVsSAnZWagAAfwkP/2zOw0Ppun7271/tMP6y\n1R0O9FZvOlAKy4/WqvLogzr5WLpMKkwSysSkHvHV163Np15/dIrv8RjvZBLr\nrk6+kbeqQNFS8OD0rresp/ZdyuBRWO6mrUNEWC/05uzUS9U2apB7bIAFjIYo\nCafFipIRakJ1GeslgrlpTRfBKQ5PVIYGZaeQrnxMAhX3NyAUgg3O4S6k8I5Y\na42CucKBZwg9FVVotRxtg7bBCSlDIuPpnU1350SauzdqrgaJcFwee4flcjeL\noF3g1Pv8iwmYZgW8vc/KQazTVhdAJt8PDddJB/FvBm/GCTRTCmdA1bchi1MV\nJhXnen/y2H8+JiKICdCyJqI5D8jhIJy4PPt9Kda49bxzgVjhIgFnlhpbBn1A\np20LBXgpmw2UehcHZVUu0n91CYLI1LHafV8u2MEGHZ59hGyiSjgaNS7YRP3i\nsRvKQwFqBunDjnkSxKiPoY1eOq7JTM37DCwNsewKjlFUSq04lx0U7hTc5Pnw\nmiYjn+35isf98E42F52C4sWbIB0+tIFU+jdPyAkSS5PH0WEVSwa85khxO4pG\nOMESUHpfd12SuU5byfEvFgZARkbDXZC0/PwKBP9hWgrJyhOMXB7Nt6pdtU1k\njZm5hQkh9Ho37x8cMHgp2qRpFWYrkNBRro3TMzQjeLjslfYGamH67HGhgPmH\nECHM\r\n=uBbG\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC26J9vZ9RrFt+UiDPC9xtDaqqdnhFI8L6khIxGerSTNAIgCk58TQvHe2Zcs3zD+Ffua80VhiWQnzU+Ut76QB5z5A8="}],"size":2435,"noattachment":false,"key":"/p-any/-/p-any-4.0.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-any_4.0.0_1622476756153_0.7281487901424866"},"_hasShrinkwrap":false,"readme":"# p-any\n\n> Wait for any promise to be fulfilled\n\nUseful when you need the fastest promise.\n\nYou probably want this instead of `Promise.race()`. [Reason.](http://bluebirdjs.com/docs/api/promise.race.html)\n\n*With [Node.js 15](https://medium.com/@nodejs/node-js-v15-0-0-is-here-deb00750f278), there's now a built-in [`Promise#any`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/any) method. The benefit of this package is that it has cancellation functionality.*\n\n## Install\n\n```\n$ npm install p-any\n```\n\n## Usage\n\nChecks 3 websites and logs the fastest.\n\n```js\nimport pAny from 'p-any';\nimport got from 'got';\n\nconst first = await pAny([\n\tgot.head('https://github.com').then(() => 'github'),\n\tgot.head('https://google.com').then(() => 'google'),\n\tgot.head('https://twitter.com').then(() => 'twitter'),\n]);\n\nconsole.log(first);\n//=> 'google'\n```\n\n## API\n\n### pAny(input, options?)\n\nReturns a [cancelable `Promise`](https://github.com/sindresorhus/p-cancelable) that is fulfilled when any promise from `input` is fulfilled. If all the `input` promises reject, it will reject with an [`AggregateError`](https://github.com/sindresorhus/aggregate-error) error.\n\n#### input\n\nType: `Iterable<Promise | unknown>`\n\n#### options\n\nType: `object`\n\n##### filter\n\nType: `Function`\n\nReceives the value resolved by the promise. Used to filter out values that doesn't satisfy a condition.\n\n### AggregateError\n\nExposed for instance checking.\n\n## Related\n\n- [p-some](https://github.com/sindresorhus/p-some) - Wait for a specified number of promises to be fulfilled\n- [p-locate](https://github.com/sindresorhus/p-locate) - Get the first fulfilled promise that satisfies the provided testing function\n- [More…](https://github.com/sindresorhus/promise-fun)\n","publish_time":1622476756288,"_cnpm_publish_time":1622476756288,"dist-tags":{"latest":"4.0.0"}}