{"_id":"p-filter","_rev":"3287397","name":"p-filter","description":"Filter promises concurrently","dist-tags":{"latest":"4.1.0"},"maintainers":[{"name":"sindresorhus","email":""}],"time":{"modified":"2024-05-23T06:34:40.000Z","created":"2016-10-21T04:16:12.722Z","4.1.0":"2023-12-27T16:02:56.291Z","4.0.0":"2023-12-22T16:01:50.571Z","3.0.0":"2021-08-12T22:59:04.308Z","2.1.0":"2019-04-04T04:54:11.010Z","2.0.0":"2019-03-13T04:13:10.234Z","1.0.0":"2016-10-21T04:16:12.722Z"},"users":{"seangenabe":true,"rocket0191":true},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-filter.git"},"versions":{"4.1.0":{"name":"p-filter","version":"4.1.0","description":"Filter promises concurrently","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-filter.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":">=18"},"scripts":{"test":"xo && ava && tsd"},"keywords":["promise","filter","collection","iterable","iterator","fulfilled","async","await","promises","concurrently","concurrency","parallel"],"dependencies":{"p-map":"^7.0.1"},"devDependencies":{"ava":"^6.0.1","tsd":"^0.30.1","xo":"^0.56.0"},"types":"./index.d.ts","gitHead":"ec5496d1ce853addb6a003652565c9223ea51fba","bugs":{"url":"https://github.com/sindresorhus/p-filter/issues"},"homepage":"https://github.com/sindresorhus/p-filter#readme","_id":"p-filter@4.1.0","_nodeVersion":"21.2.0","_npmVersion":"9.2.0","dist":{"shasum":"fe0aa794e2dfad8ecf595a39a245484fcd09c6e4","size":2676,"noattachment":false,"key":"/p-filter/-/p-filter-4.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-filter/download/p-filter-4.1.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-filter_4.1.0_1703692976091_0.9156248707343033"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-12-27T16:02:56.291Z","publish_time":1703692976291,"_source_registry_name":"default","_cnpm_publish_time":1703692976291},"4.0.0":{"name":"p-filter","version":"4.0.0","description":"Filter promises concurrently","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-filter.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":">=18"},"scripts":{"test":"xo && ava && tsd"},"keywords":["promise","filter","collection","iterable","iterator","fulfilled","async","await","promises","concurrently","concurrency","parallel"],"dependencies":{"p-map":"^7.0.0"},"devDependencies":{"ava":"^6.0.1","tsd":"^0.30.0","xo":"^0.56.0"},"types":"./index.d.ts","gitHead":"def98651f6e086e10d05cf2be49795fb4caba418","bugs":{"url":"https://github.com/sindresorhus/p-filter/issues"},"homepage":"https://github.com/sindresorhus/p-filter#readme","_id":"p-filter@4.0.0","_nodeVersion":"21.2.0","_npmVersion":"9.2.0","dist":{"shasum":"10d55bf804712a1301a9bfb1588d5ec641cce754","size":2665,"noattachment":false,"key":"/p-filter/-/p-filter-4.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-filter/download/p-filter-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-filter_4.0.0_1703260910374_0.4073599827487109"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-12-22T16:01:50.571Z","publish_time":1703260910571,"_source_registry_name":"default","_cnpm_publish_time":1703260910571},"3.0.0":{"name":"p-filter","version":"3.0.0","description":"Filter promises concurrently","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-filter.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.0 || ^14.13.1 || >=16.0.0"},"scripts":{"test":"xo && ava && tsd"},"keywords":["promise","filter","collection","iterable","iterator","fulfilled","async","await","promises","concurrently","concurrency","parallel","bluebird"],"dependencies":{"p-map":"^5.1.0"},"devDependencies":{"ava":"^3.15.0","tsd":"^0.17.0","xo":"^0.44.0"},"gitHead":"befd29e865210d858cbacda364b30c2cca1384e9","bugs":{"url":"https://github.com/sindresorhus/p-filter/issues"},"homepage":"https://github.com/sindresorhus/p-filter#readme","_id":"p-filter@3.0.0","_nodeVersion":"12.22.1","_npmVersion":"7.10.0","dist":{"shasum":"ce50e03b24b23930e11679ab8694bd09a2d7ed35","size":2315,"noattachment":false,"key":"/p-filter/-/p-filter-3.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-filter/download/p-filter-3.0.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-filter_3.0.0_1628809144118_0.30858885067994235"},"_hasShrinkwrap":false,"publish_time":1628809144308,"_cnpm_publish_time":1628809144308},"2.1.0":{"name":"p-filter","version":"2.1.0","description":"Filter promises concurrently","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-filter.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=8"},"scripts":{"test":"xo && ava && tsd"},"keywords":["promise","filter","collection","iterable","iterator","fulfilled","async","await","promises","concurrently","concurrency","parallel","bluebird"],"dependencies":{"p-map":"^2.0.0"},"devDependencies":{"ava":"^1.4.1","tsd":"^0.7.2","xo":"^0.24.0"},"gitHead":"095943f96513f7eb5da9b9ae944344fe954af82d","bugs":{"url":"https://github.com/sindresorhus/p-filter/issues"},"homepage":"https://github.com/sindresorhus/p-filter#readme","_id":"p-filter@2.1.0","_nodeVersion":"8.15.0","_npmVersion":"6.9.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"1b1472562ae7a0f742f0f3d3d3718ea66ff9c09c","size":2603,"noattachment":false,"key":"/p-filter/-/p-filter-2.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-filter/download/p-filter-2.1.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-filter_2.1.0_1554353650849_0.39423971424215853"},"_hasShrinkwrap":false,"publish_time":1554353651010,"_cnpm_publish_time":1554353651010},"2.0.0":{"name":"p-filter","version":"2.0.0","description":"Filter promises concurrently","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-filter.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=8"},"scripts":{"test":"xo && ava && tsd-check"},"keywords":["promise","filter","collection","iterable","iterator","fulfilled","async","await","promises","concurrently","concurrency","parallel","bluebird"],"dependencies":{"p-map":"^2.0.0"},"devDependencies":{"ava":"^1.3.1","tsd-check":"^0.3.0","xo":"^0.24.0"},"gitHead":"99ea1ad59cf434af1c05023b47817f4f550e95ed","bugs":{"url":"https://github.com/sindresorhus/p-filter/issues"},"homepage":"https://github.com/sindresorhus/p-filter#readme","_id":"p-filter@2.0.0","_nodeVersion":"8.15.0","_npmVersion":"6.9.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"08f3d1f214aa2ab15d3a306dd65c13d3a4a07900","size":2390,"noattachment":false,"key":"/p-filter/-/p-filter-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-filter/download/p-filter-2.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-filter_2.0.0_1552450390067_0.7734956600652936"},"_hasShrinkwrap":false,"publish_time":1552450390234,"_cnpm_publish_time":1552450390234},"1.0.0":{"name":"p-filter","version":"1.0.0","description":"Filter promises concurrently","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-filter.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=4"},"scripts":{"test":"xo && ava"},"files":["index.js"],"keywords":["promise","filter","collection","iterable","iterator","fulfilled","async","await","promises","concurrently","concurrency","parallel","bluebird"],"dependencies":{"p-map":"^1.0.0"},"devDependencies":{"ava":"*","xo":"*"},"xo":{"esnext":true},"gitHead":"92325d87416a43dac04fdc32b9e9a86fbd5171ac","bugs":{"url":"https://github.com/sindresorhus/p-filter/issues"},"homepage":"https://github.com/sindresorhus/p-filter#readme","_id":"p-filter@1.0.0","_shasum":"629d317150209c8fd508ba137713ef4bb920e9db","_from":".","_npmVersion":"2.15.9","_nodeVersion":"4.6.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"629d317150209c8fd508ba137713ef4bb920e9db","size":2106,"noattachment":false,"key":"/p-filter/-/p-filter-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-filter/download/p-filter-1.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/p-filter-1.0.0.tgz_1477023370757_0.32707744953222573"},"directories":{},"publish_time":1477023372722,"_cnpm_publish_time":1477023372722,"_hasShrinkwrap":false}},"readme":"# p-filter\n\n> Filter promises concurrently\n\nUseful when you need to run promise-returning & async functions multiple times with different inputs concurrently and get a filtered down result.\n\n## Install\n\n```sh\nnpm install p-filter\n```\n\n## Usage\n\n```js\nimport pFilter from 'p-filter';\nimport getWeather from 'get-weather'; // Not a real module\n\nconst places = [\n\tgetCapital('Norway').then(info => info.name),\n\t'Bangkok, Thailand',\n\t'Berlin, Germany',\n\t'Tokyo, Japan',\n];\n\nconst filterer = async place => {\n\tconst weather = await getWeather(place);\n\treturn weather.temperature > 30;\n};\n\nconst result = await pFilter(places, filterer);\n\nconsole.log(result);\n//=> ['Bangkok, Thailand']\n```\n\n## API\n\n### pFilter(input, filterer, options?)\n\nReturns a `Promise` that is fulfilled when all promises in `input` and ones returned from `filterer` are fulfilled, or rejects if any of the promises reject. The fulfilled value is an `Array` of the fulfilled values returned from `filterer` in `input` order.\n\n#### input\n\nType: `Iterable<Promise<unknown> | unknown>`\n\nIterated over concurrently in the `filterer` function.\n\n#### filterer(element, index)\n\nType: `Function`\n\nThe filterer function that decides whether an element should be included into result. Expected to return `boolean | Promise<boolean>`.\n\n#### options\n\nType: `object`\n\nSee the [`p-map` options](https://github.com/sindresorhus/p-map#options).\n\n##### concurrency\n\nType: `number`\\\nDefault: `Infinity`\\\nMinimum: `1`\n\nThe number of concurrently pending promises returned by `filterer`.\n\n### pFilterIterable(iterable, filterer, options?)\n\nReturns an async iterable that iterates over the promises in `iterable` and ones returned from `filterer` concurrently, calling `filterer` for each element.\n\n```js\nimport {pFilterIterable} from 'p-filter';\nimport getWeather from 'get-weather'; // Not a real module\n\nasync function * getPlaces() {\n\tconst name = await getCapital('Norway');\n\n\tyield name;\n\tyield 'Bangkok, Thailand';\n\tyield 'Berlin, Germany';\n\tyield 'Tokyo, Japan';\n}\n\nconst places = getPlaces();\n\nconst filterer = async place => {\n\tconst weather = await getWeather(place);\n\treturn weather.temperature > 30;\n};\n\nfor await (const element of pFilterIterable(places, filterer)) {\n\tconsole.log(element);\n}\n//=> ['Bangkok, Thailand']\n```\n\n#### iterable\n\nType: `Iterable<Promise<unknown> | unknown>`\n\nIterated over concurrently in the `filterer` function.\n\n#### filterer(element, index)\n\nType: `Function`\n\nThe filterer function that decides whether an element should be included into result. Expected to return `boolean | Promise<boolean>`.\n\n#### options\n\nType: `object`\n\nSee the [`p-map` options](https://github.com/sindresorhus/p-map#options).\n\n##### concurrency\n\nType: `number`\\\nDefault: `Infinity`\\\nMinimum: `1`\n\nThe number of concurrently pending promises returned by `filterer`.\n\n## Related\n\n- [p-locate](https://github.com/sindresorhus/p-locate) - Get the first fulfilled promise that satisfies the provided testing function\n- [p-map](https://github.com/sindresorhus/p-map) - Map over promises concurrently\n- [p-times](https://github.com/sindresorhus/p-times) - Run promise-returning & async functions a specific number of times concurrently\n- [More…](https://github.com/sindresorhus/promise-fun)\n","_attachments":{},"homepage":"https://github.com/sindresorhus/p-filter#readme","bugs":{"url":"https://github.com/sindresorhus/p-filter/issues"},"license":"MIT"}