{"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":{"integrity":"sha512-QtoWLjXAW++uTX67HZQz1dbTpqBfiidsB6VtQUC9iR85S120+s0T5sO6s+B5MLzFcZkrEd/DGMmCjR+f2Qpxwg==","shasum":"ce50e03b24b23930e11679ab8694bd09a2d7ed35","tarball":"http://registry-npm.ywwl.com/p-filter/download/p-filter-3.0.0.tgz","fileCount":5,"unpackedSize":5092,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhFae4CRA9TVsSAnZWagAAGzAP/Ry1w1EINguewyCd1BVw\n0hJ/Z8VZps5ftgN2LnmEMQON9XpittnW5ZYRJTDTfR5l2+2gvQwGNASjtKF/\nAzom1+XeSLFM5mP/IQEwyqIhd2mV1Qle8jbUbIcvCb98wAFiFGor7dQtJYaI\nKovdZ6sM+IOiFE6M/nQFfaYBSrTVd/yAGXegTCFSy/oBB7Cgf4Dkew2kDMr+\n5Vr57vp4xFIto4Bsp/DqU76cka+X7yqg84E0focHxK4rIcnY28gruraUtq1X\noDWxZKsD8MIKVQBCYviz/SCWsFxxEHJMRreCJAvZW/Aa//Kz6PuxZ85/oZrb\nZDDJjmNNNjhB3ypK7FW4Uk+KrXMRV6/9w5NO3YN7+GJBANuZNTBUQIcH/Kir\nNoOAIAEBp0kOGmz11CjYmKNRTZ/xwlQbIQ09LuElRjznoiC+Xf+SJSjKp/+G\nVVT8rSS2VqaKvJeFTHpKsGkXnNYvx9VhTij5AZ66bUdXIP28fZkAX7dwkBvt\nXHJVHo0bcNiDsB2mBTfY94nol2qMPq8Dfme12WXgsv+3suWyvqg9R3rjK/cL\ndPM9QiWhThfG84dLDj0S8GSjsYEhu08xFvDzpoyZgIxFpdIEE98FKL6bs3BW\nPH567oEKMs5mFjZykD/xiPHNjbi5otC7+/w38lrOHhBj/hzlTd3fsLML13Nu\nVJsI\r\n=pzxj\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDpGBaTHNP1heYqtLom6iTfOQw4Jugp4E63Iq7pFgPcfAiACZixP7yVd2Iz7uF1AJRqYZRK0XNtNjLU710FFGfnlNA=="}],"size":2315,"noattachment":false,"key":"/p-filter/-/p-filter-3.0.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-filter_3.0.0_1628809144118_0.30858885067994235"},"_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","publish_time":1628809144308,"_cnpm_publish_time":1628809144308,"dist-tags":{"latest":"4.1.0"}}