{"_id":"p-any","_rev":"411825","name":"p-any","description":"Wait for any promise to be fulfilled","dist-tags":{"latest":"4.0.0"},"maintainers":[{"name":"sindresorhus","email":""}],"time":{"modified":"2021-08-04T05:11:01.000Z","created":"2016-10-21T05:37:21.204Z","4.0.0":"2021-05-31T15:59:16.288Z","3.0.0":"2020-02-22T14:44:06.005Z","2.1.0":"2019-04-04T03:31:33.317Z","2.0.0":"2019-03-14T18:03:49.315Z","1.1.0":"2017-06-13T00:22:38.884Z","1.0.0":"2016-10-21T05:37:21.204Z"},"users":{"rocket0191":true},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-any.git"},"versions":{"4.0.0":{"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":{"shasum":"0e9c8b0fa3e58cc79e6a1c6c715aa9326b6a4447","size":2435,"noattachment":false,"key":"/p-any/-/p-any-4.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-any/download/p-any-4.0.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-any_4.0.0_1622476756153_0.7281487901424866"},"_hasShrinkwrap":false,"publish_time":1622476756288,"_cnpm_publish_time":1622476756288},"3.0.0":{"name":"p-any","version":"3.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"},"engines":{"node":">=10"},"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":"^5.0.0"},"devDependencies":{"ava":"^1.4.1","delay":"^4.1.0","tsd":"^0.11.0","xo":"^0.26.1"},"gitHead":"f8fdada8495f4a046064b5d49bbb3488be6e61bd","bugs":{"url":"https://github.com/sindresorhus/p-any/issues"},"homepage":"https://github.com/sindresorhus/p-any#readme","_id":"p-any@3.0.0","_nodeVersion":"10.18.1","_npmVersion":"6.13.4","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"79847aeed70b5d3a10ea625296c0c3d2e90a87b9","size":2403,"noattachment":false,"key":"/p-any/-/p-any-3.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-any/download/p-any-3.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-any_3.0.0_1582382645910_0.12211509883760985"},"_hasShrinkwrap":false,"publish_time":1582382646005,"_cnpm_publish_time":1582382646005},"2.1.0":{"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":{"shasum":"719489408e14f5f941a748f1e817f5c71cab35cb","size":2498,"noattachment":false,"key":"/p-any/-/p-any-2.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-any/download/p-any-2.1.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-any_2.1.0_1554348693198_0.47988170192884816"},"_hasShrinkwrap":false,"publish_time":1554348693317,"_cnpm_publish_time":1554348693317},"2.0.0":{"name":"p-any","version":"2.0.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-check"},"keywords":["promise","any","resolved","wait","collection","iterable","iterator","race","fulfilled","fastest","one","single","async","await","promises","bluebird"],"dependencies":{"p-cancelable":"^1.1.0","p-some":"^4.0.0","type-fest":"^0.1.0"},"devDependencies":{"ava":"^1.3.1","delay":"^4.1.0","tsd-check":"^0.3.0","xo":"^0.24.0"},"gitHead":"24a9cd4c4455c61ab6b14ba75a080e545886214b","bugs":{"url":"https://github.com/sindresorhus/p-any/issues"},"homepage":"https://github.com/sindresorhus/p-any#readme","_id":"p-any@2.0.0","_nodeVersion":"8.15.0","_npmVersion":"6.9.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"4a80c8a7ce59614190132c1f905df95d3bf7b58f","size":2346,"noattachment":false,"key":"/p-any/-/p-any-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-any/download/p-any-2.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-any_2.0.0_1552586629187_0.13780460970476294"},"_hasShrinkwrap":false,"publish_time":1552586629315,"_cnpm_publish_time":1552586629315},"1.1.0":{"name":"p-any","version":"1.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":">=4"},"scripts":{"test":"xo && ava"},"files":["index.js"],"keywords":["promise","any","resolved","wait","collection","iterable","iterator","race","fulfilled","fastest","one","single","async","await","promises","bluebird"],"dependencies":{"p-some":"^2.0.0"},"devDependencies":{"ava":"*","delay":"^2.0.0","xo":"*"},"gitHead":"a3c40833ea2c2ea671709ebb9bab9674c5e60b7a","bugs":{"url":"https://github.com/sindresorhus/p-any/issues"},"homepage":"https://github.com/sindresorhus/p-any#readme","_id":"p-any@1.1.0","_npmVersion":"5.0.0","_nodeVersion":"8.0.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"1d03835c7eed1e34b8e539c47b7b60d0d015d4e1","size":1994,"noattachment":false,"key":"/p-any/-/p-any-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-any/download/p-any-1.1.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-any-1.1.0.tgz_1497313357479_0.6320313415490091"},"directories":{},"publish_time":1497313358884,"_hasShrinkwrap":false,"_cnpm_publish_time":1497313358884},"1.0.0":{"name":"p-any","version":"1.0.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":">=4"},"scripts":{"test":"xo && ava"},"files":["index.js"],"keywords":["promise","any","resolved","wait","collection","iterable","iterator","race","fulfilled","race","fastest","one","single","async","await","promises","bluebird"],"dependencies":{"p-some":"^1.0.0"},"devDependencies":{"ava":"*","delay":"^1.3.1","xo":"*"},"xo":{"esnext":true},"gitHead":"0a45e39e5f4bdf4fb23c6a4c6c9d079152deb645","bugs":{"url":"https://github.com/sindresorhus/p-any/issues"},"homepage":"https://github.com/sindresorhus/p-any#readme","_id":"p-any@1.0.0","_shasum":"5c1710b63970d5ac4e2c5ae989b896f26cd39afa","_from":".","_npmVersion":"2.15.9","_nodeVersion":"4.6.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"5c1710b63970d5ac4e2c5ae989b896f26cd39afa","size":1887,"noattachment":false,"key":"/p-any/-/p-any-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-any/download/p-any-1.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/p-any-1.0.0.tgz_1477028240961_0.3575032774824649"},"directories":{},"publish_time":1477028241204,"_cnpm_publish_time":1477028241204,"_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","_attachments":{},"homepage":"https://github.com/sindresorhus/p-any#readme","bugs":{"url":"https://github.com/sindresorhus/p-any/issues"},"license":"MIT"}