{"name":"p-some","version":"7.0.0","description":"Wait for a specified number of promises to be fulfilled","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-some.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"sideEffects":false,"engines":{"node":">=20"},"scripts":{"test":"xo && ava && tsc index.d.ts --lib es2015,dom"},"keywords":["promise","some","resolved","wait","collection","iterable","iterator","race","fulfilled","fastest","async","await","promises","bluebird"],"devDependencies":{"ava":"^6.4.1","delay":"^6.0.0","typescript":"^5.9.2","xo":"^1.2.2"},"_id":"p-some@7.0.0","gitHead":"1fd790802c97d24bab4ecee77e0d925394d07d77","types":"./index.d.ts","bugs":{"url":"https://github.com/sindresorhus/p-some/issues"},"homepage":"https://github.com/sindresorhus/p-some#readme","_nodeVersion":"20.19.1","_npmVersion":"10.9.2","dist":{"integrity":"sha512-9ldWF6puBzuchsUq7M1THjwwmoiXesqRdpB4WH0D7urKXdGkIaDqVhQS2BSfRRYZ970j9gm3U4/h9hHQx2G1Ug==","shasum":"88d61e9818feab2ef32df4ac0d1327e5424538ed","tarball":"http://registry-npm.ywwl.com/p-some/download/p-some-7.0.0.tgz","fileCount":5,"unpackedSize":12599,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDj+tUy6Rn1xZ7555NjaDrmVaxxwAVBBGSmWh46aWQYIQIhAOzz2QYruIczJgHaWatiR4NhvPlsTulB20EQX/a+/G/S"}],"size":4014,"noattachment":false,"key":"/p-some/-/p-some-7.0.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/p-some_7.0.0_1757596870535_0.15236703384157457"},"_hasShrinkwrap":false,"readme":"# p-some\n\n> Wait for a specified number of promises to be fulfilled\n\nUseful when you need the fastest of multiple promises.\n\n## Install\n\n```sh\nnpm install p-some\n```\n\n## Usage\n\nChecks 4 websites and logs the 2 fastest.\n\n```js\nimport got from 'got';\nimport pSome from 'p-some';\n\nconst input = [\n\tgot.head('github.com').then(() => 'github'),\n\tgot.head('google.com').then(() => 'google'),\n\tgot.head('twitter.com').then(() => 'twitter'),\n\tgot.head('medium.com').then(() => 'medium')\n];\n\nconst [first, second] = await pSome(input, {count: 2});\n\nconsole.log(first, second);\n//=> 'google twitter'\n```\n\n## API\n\n### pSome(input, options)\n\nReturns a `Promise` that is fulfilled when `count` promises from `input` are fulfilled. The fulfilled value is an `Array` of the values from the `input` promises in the order they were fulfilled. If it becomes impossible to satisfy `count`, for example, too many promises rejected, it will reject with an `AggregateError`. The promise can be aborted using the `signal` option.\n\n#### input\n\nType: `Iterable<Promise | unknown>`\n\nAn `Iterable` collection of promises/values to wait for.\n\n#### options\n\nType: `object`\n\n##### count\n\n*Required*\\\nType: `number`\\\nMinimum: `1`\n\nNumber of promises from `input` that have to be fulfilled until the returned promise is fulfilled.\n\n##### filter\n\nType: `Function`\n\nReceives the value resolved by the promise. Used to filter out values that don't satisfy a condition.\n\nThe filter function can return either a boolean directly or a Promise that resolves to a boolean.\n\nExample with async filter:\n\n```js\nimport got from 'got';\nimport pSome from 'p-some';\n\nconst input = [\n\tgot('api.github.com').then(response => response.body),\n\tgot('api.twitter.com').then(response => response.body),\n\tgot('api.reddit.com').then(response => response.body)\n];\n\n// Only include responses that contain certain data (async check)\nconst result = await pSome(input, {\n\tcount: 2,\n\tasync filter(response) {\n\t\t// Simulate async validation (e.g., database lookup)\n\t\tawait new Promise(resolve => setTimeout(resolve, 10));\n\t\treturn response.includes('api');\n\t}\n});\n```\n\n##### signal\n\nType: `AbortSignal`\n\n[AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) to abort the operation.\n\n### pEvery(input, testFunction, options?)\n\nTest whether all promises pass a testing function.\n\nReturns a Promise that resolves to `true` only if **every** item makes `testFunction` resolve to `true`. Resolves to `false` if any item makes it resolve to `false`. **Rejects** if any input or `testFunction` throws or rejects.\n\n```js\nimport {pEvery} from 'p-some';\n\nconst result = await pEvery([\n\tPromise.resolve(2),\n\tPromise.resolve(4),\n\tPromise.resolve(6)\n], value => value % 2 === 0);\n\nconsole.log(result);\n//=> true\n```\n\n#### input\n\nType: `Iterable<Promise | unknown>`\n\nAn `Iterable` collection of promises/values to test.\n\n#### testFunction\n\nType: `Function`\n\nThe function to test each promise with. Can be async.\n\n#### options\n\nType: `object`\n\n##### concurrency\n\nType: `number`\\\nDefault: `Infinity`\\\nMinimum: `1`\n\nNumber of input items tested concurrently.\n\n##### signal\n\nType: `AbortSignal`\n\n[AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) to abort the operation.\n\n### FilterError\n\nExposed for instance checking.\n\n## Related\n\n- [p-any](https://github.com/sindresorhus/p-any) - Wait for any promise to be fulfilled\n- [More…](https://github.com/sindresorhus/promise-fun)\n","publish_time":1757596870688,"_cnpm_publish_time":1757596870688,"dist-tags":{"latest":"8.0.0"}}