{"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","tarball":"http://registry-npm.ywwl.com/p-any/download/p-any-1.0.0.tgz","integrity":"sha512-Mha8rTTz0VoPd52JVMShGVh20a8oDD++tGltTur/rXwNSXJfRW+isP1mNTp2c3FjXcUptw3Njg8BA2esnyE6aw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCtDGNbqzJWntGLLazGNkpbzntSYEz+5YDlkQx8xaEzHQIgUzNtROcm6CoLv5PmtxFjvJe7CrrB9UIYkFpU2LlyTeE="}],"size":1887,"noattachment":false,"key":"/p-any/-/p-any-1.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/p-any-1.0.0.tgz_1477028240961_0.3575032774824649"},"directories":{},"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":1477028241204,"_cnpm_publish_time":1477028241204,"dist-tags":{"latest":"4.0.0"}}