{"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":{"integrity":"sha512-y0j4GHE3Vsj0GsmPCsaR6gvCDb5kJSIs87fL+Buhka/d/zk+VOmHNGADkE/QEIMH5Na4/sm7LrwXfT2fq8ZXGA==","shasum":"08f3d1f214aa2ab15d3a306dd65c13d3a4a07900","tarball":"http://registry-npm.ywwl.com/p-filter/download/p-filter-2.0.0.tgz","fileCount":5,"unpackedSize":4816,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJciINWCRA9TVsSAnZWagAAp5IQAKNAmoK0sB7+/3XlS+nU\n7QhpgOxULtVWJAMGYW3GU8o/kwBMmeYWyKo02ARevGiBZBEXvHmTypCeFDG0\n/ehTJDd3OUSahtgueH4f39otgjPc9K3ZtcXPJgzhYLG98eGTamazELdyJ9Hi\n4y0K8X/trQO7MLMsX3jEcGUsEidBJV95ABWZPsyq6RcAEXmfOnS/6b8u3Xoq\ns6FcQspniWF3LQ93izseFB3qAd6W1c91X9kVF2P4ZQS3j+LQfyyA3gIJblR2\nDHTQHz0MvGtjv+w+vDWMFurGlyffCG9WSasId3DoU/z2Yu3kDZBc2emaJneu\nlRzggFEI5dCk5QtvO+Sfd+nDsBAqO1mwQ9YqAW3DNCjouSW49sj9d4tpox1e\nKy1mVx9GbbqgwsYl8Ji2Lca8qCg29TDEETneUBs/fUW1OwIkPmllZ0l9c4lU\nnNBLghstCKLKhqOhB3F6ic4gSMZHhf6Yv4hhfcmegU27s907q/vtGeyXPGBs\nZRDjoM4w5SDw/K54/WtaB81XTjliCH5U6KEH9zmv4syvYPBd6jh+ZWozS+sl\n4zWndEn/Z4DVJZlGfMOlpRfRzu8scIXug/vBrx6oCElEhKYgIvM/GXH8Q2w3\ncNInlj+Jc9Idh6jPH/j4Cl8oYWglvi6+b35PinUn44FK5TbDIOpw1Mijn6Ei\n872O\r\n=6ING\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC7IEMKqnU5BwAczc94oPOBSYUdtHzHFl5nukljMILZ4wIgfs/xKQnYt6Y8vyf+vkncqP7aU5qA+TmHq0zhrWSPv9E="}],"size":2390,"noattachment":false,"key":"/p-filter/-/p-filter-2.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-filter_2.0.0_1552450390067_0.7734956600652936"},"_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":1552450390234,"_cnpm_publish_time":1552450390234,"dist-tags":{"latest":"4.1.0"}}