{"name":"p-any","version":"2.1.0","description":"Wait for any promise to be fulfilled","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-any.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=8"},"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":"^2.0.0","p-some":"^4.0.0","type-fest":"^0.3.0"},"devDependencies":{"ava":"^1.4.1","delay":"^4.1.0","tsd":"^0.7.2","xo":"^0.24.0"},"gitHead":"78331617179bdcd93f5ef0e25a163df430dff6e6","bugs":{"url":"https://github.com/sindresorhus/p-any/issues"},"homepage":"https://github.com/sindresorhus/p-any#readme","_id":"p-any@2.1.0","_nodeVersion":"8.15.0","_npmVersion":"6.9.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"integrity":"sha512-JAERcaMBLYKMq+voYw36+x5Dgh47+/o7yuv2oQYuSSUml4YeqJEFznBrY2UeEkoSHqBua6hz518n/PsowTYLLg==","shasum":"719489408e14f5f941a748f1e817f5c71cab35cb","tarball":"http://registry-npm.ywwl.com/p-any/download/p-any-2.1.0.tgz","fileCount":5,"unpackedSize":5606,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcpXqVCRA9TVsSAnZWagAAVosP/3hOrP4h9fpqBSMkhD6Y\nSkFuESAYhnsP5UYnPcumouj6pvsx9ljrQ6zO2cMEYKwqg4gK2192THHJBsXj\nzPQdBHAosN+vI2UiBJOnZtRCIKePf4dggQrUS/kDLXOAd/ze132iVHS/ZQ6O\nlgdtclb+/UeIqDml+5sNyQ5EAEXCaLrHjM4U9+jAk5GC8HEUwa+9FuBDP+66\nw1vfP3yIpJORuDogiv3e80xwajkxTgGMrcDG0l8th/zpe28huOxVOlQq5TRH\nd7gr9HX3yj5We3dWmCHVukP3SgovqlEp8vOI+WyKeP92ZBlWBndtynsZEuOE\n1ikmVlA2lkHlLsJtKs4Kzej6fKK9rcKxwt18F6I26ACncrV+InuCdIJEvYcm\nFTQj8pUosGkR/+JOjQNlebB+RcalwXImNXX7S1qeNjTslsio460+3OXO/BW1\nylvAqcJpHgoknKRbLzRFz1JU8gspssuNcZH4Pvf/WCsebFYn//mhXebPyJ1b\nHwotx1PgbD8cDFkDkIZdXy9P3cKF8Gf4hEueQVWo7XoH2NQe8Zw6R1MOfyqm\nQTkhT5gxlDqfPlV+aYb0SVTp2hInRr2COqBH40SXcUIkaJq25n4dcrswPmO7\nnhSoOr1tFX7yY97BZ/eQn/9CMyIAku3+Uo5uwvDAabo3V7WQWACqOg9RsGGY\ncqV4\r\n=SpLx\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGt9xCOS5ZjFQtRzJAQJGcA/iF9T/RWKhncS4w3IfBHkAiAQZ+MpOfC5MVVGHY6vZiJmX9ldLhcr0e6MnSDTamIYug=="}],"size":2498,"noattachment":false,"key":"/p-any/-/p-any-2.1.0.tgz"},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-any_2.1.0_1554348693198_0.47988170192884816"},"_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":1554348693317,"_cnpm_publish_time":1554348693317,"dist-tags":{"latest":"4.0.0"}}