{"_id":"p-some@8.0.0","bugs":{"url":"https://github.com/sindresorhus/p-some/issues"},"dist":{"shasum":"405a6d27a18ed57554a3c644a54ead57d3f0b5af","tarball":"http://registry-npm.ywwl.com/p-some/download/p-some-8.0.0.tgz","fileCount":5,"integrity":"sha512-EWatdXRf2tNunroQEh2RZIqxW4Zf8KWDltbfD5uggcggKj6dAoQ3IuRp2G5MLQM5dZ5CjceHh2o0vw37jNNuAw==","signatures":[{"sig":"MEQCID3FdP0rCu96YKimmqRaRV7PiGp1HkHA2FPIOxaX6+qKAiAjEUaSy6z+1nVIoZvZ1wDaFkpu/VQr5X0XbMq+XPrifg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCkqMGfLI4sbp2vZ0FmDCRqa4bMUJXmAZurflNitp0F8wIhAJVYSZWZncYKIsJWN+p5jSlhSfLmEpum0y7zH11LhXPv"}],"unpackedSize":14588,"size":4623,"noattachment":false,"key":"/p-some/-/p-some-8.0.0.tgz"},"name":"p-some","type":"module","types":"./index.d.ts","author":{"url":"https://sindresorhus.com","name":"Sindre Sorhus","email":"sindresorhus@gmail.com"},"engines":{"node":">=22"},"exports":{"types":"./index.d.ts","default":"./index.js"},"funding":"https://github.com/sponsors/sindresorhus","gitHead":"59fc9af881d9cbf0aa5d2cb551a82e435b1af1ad","license":"MIT","scripts":{"test":"xo && node --test --test-timeout=30000 && tsc index.d.ts --lib es2015,dom"},"version":"8.0.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"homepage":"https://github.com/sindresorhus/p-some#readme","keywords":["promise","some","resolved","wait","collection","iterable","iterator","race","fulfilled","fastest","async","await","promises","bluebird"],"repository":{"url":"git+https://github.com/sindresorhus/p-some.git","type":"git"},"_npmVersion":"12.2.0","description":"Wait for a specified number of promises to be fulfilled","directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"sideEffects":false,"_nodeVersion":"26.12.1","_hasShrinkwrap":false,"devDependencies":{"xo":"^5.0.1","typescript":"^6.0.3"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/p-some_8.0.0_1793651736292_0.659899090955286"},"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 and their values pass `filter`. The fulfilled value is an `Array` of those values in the order they pass `filter`. If it becomes impossible to satisfy `count`, for example, too many promises rejected or too few values pass `filter`, 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\nWith an async filter, selection and ordering depend on when filter calls resolve to `true`.\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":1793651736377,"_cnpm_publish_time":1793651736377,"dist-tags":{"latest":"8.0.0"}}