{"name":"p-locate","version":"4.0.0","description":"Get the first fulfilled promise that satisfies the provided testing function","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-locate.git"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"engines":{"node":">=8"},"scripts":{"test":"xo && ava && tsd-check"},"keywords":["promise","locate","find","finder","search","searcher","test","array","collection","iterable","iterator","race","fulfilled","fastest","async","await","promises","bluebird"],"dependencies":{"p-limit":"^2.0.0"},"devDependencies":{"ava":"^1.3.1","delay":"^4.1.0","in-range":"^1.0.0","time-span":"^3.0.0","tsd-check":"^0.3.0","xo":"^0.24.0"},"gitHead":"44264731678d799f596872cb9ca73e0a3de4232f","bugs":{"url":"https://github.com/sindresorhus/p-locate/issues"},"homepage":"https://github.com/sindresorhus/p-locate#readme","_id":"p-locate@4.0.0","_nodeVersion":"8.15.0","_npmVersion":"6.9.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"integrity":"sha512-IvOiDT1hbCdrsFKKXs8AGjxouEfn9VVdz/edtT08IDr+RIn2U/o3Xx+Agx455+CkSRdomMs3EN5BgR2Q0LZX0g==","shasum":"fff5d4a5dc4f89babe7d266f6efc685630038651","tarball":"http://registry-npm.ywwl.com/p-locate/download/p-locate-4.0.0.tgz","fileCount":5,"unpackedSize":6497,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJch3/xCRA9TVsSAnZWagAAuMAP/iZR3kJxFychHmDujPN+\n3CIDeLHjBI2yrvKAmEWbxwo5Ee3/6yWSvS8fq5RDEa9flvrgum2Zm5sMvWZI\nLYmGgybjMulLGIdrldnwI8YEQn4tJ0JGDc9xaOGkD6Ld0RZSz4NdnsJLvAr2\ngqAVQMZlcPs6IXKC+Peqbt9QNdN+Vw/tzF+XHhcZGgHQRaWqMZMOFv9v0i1v\nEpVKbr7isYJ9X2t9L2QrQQ7psmSRa6q9bC2TcoLHYr1r+jt8AN4cfhS9JimH\nXtMRFJ5f/SXJi8VIUwI9Q7zsMpfVrX8j4LTVIr4CF6Rwt1j3EvpKIrjweoFz\n/Z1c3jvW1EJv6lJh9aJHonCyOM/E8Z5ggHrpYvOEgJDAVokB3vRByZQPiXFq\nRB5/6t8jP1BVtMQAmdHqUT2O4BhawaGVqLV3yMU7T1VO8x6f1tvlo355wuAu\ntAPuEnTtxvXW0i7RbEwliKWEXAc7d9suLZnwSthXO54tkpnOlK6cuMHA6/yD\nf5alm8CbPC/6++RkyTIgvy09FXAMcMGjV6C5MOHNnZyBitf7byM8mHX1djD9\n2fLn19cKjeXdMBiyOmyId3wrmsr5UaLzQpqZGYBJ7/hPzyYOC0D2XQqS2BW1\nf6agqKHfAC2UTi7kVRikGiocMWW9bOjL+JNozSVidzH95QoE3jw2sdDx1CGY\nZ0FU\r\n=jasz\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD6woOiJbVK2Xn5viDHR+R1sjHjkrdHtsLziBHU6J+GwgIgFsPIawfTvitt07w8QSgMebRSyhzlDbvzAjKyVA942hg="}],"size":2916,"noattachment":false,"key":"/p-locate/-/p-locate-4.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-locate_4.0.0_1552383984361_0.08899244113594595"},"_hasShrinkwrap":false,"readme":"# p-locate\n\n> Get the first fulfilled promise that satisfies the provided testing function\n\nThink of it like an async version of [`Array#find`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/find).\n\n## Install\n\n```\n$ npm install p-locate\n```\n\n## Usage\n\nHere we find the first file that exists on disk, in array order.\n\n```js\nimport {pathExists} from 'path-exists';\nimport pLocate from 'p-locate';\n\nconst files = [\n\t'unicorn.png',\n\t'rainbow.png', // Only this one actually exists on disk\n\t'pony.png'\n];\n\nconst foundPath = await pLocate(files, file => pathExists(file));\n\nconsole.log(foundPath);\n//=> 'rainbow'\n```\n\n*The above is just an example. Use [`locate-path`](https://github.com/sindresorhus/locate-path) if you need this.*\n\n## API\n\n### pLocate(input, tester, options?)\n\nReturns a `Promise` that is fulfilled when `tester` resolves to `true` or the iterable is done, or rejects if any of the promises reject. The fulfilled value is the current iterable value or `undefined` if `tester` never resolved to `true`.\n\n#### input\n\nType: `Iterable<Promise | unknown>`\n\nAn iterable of promises/values to test.\n\n#### tester(element)\n\nType: `Function`\n\nThis function will receive resolved values from `input` and is expected to return a `Promise<boolean>` or `boolean`.\n\n#### options\n\nType: `object`\n\n##### concurrency\n\nType: `number`\\\nDefault: `Infinity`\\\nMinimum: `1`\n\nThe number of concurrently pending promises returned by `tester`.\n\n##### preserveOrder\n\nType: `boolean`\\\nDefault: `true`\n\nPreserve `input` order when searching.\n\nDisable this to improve performance if you don't care about the order.\n\n## Related\n\n- [p-map](https://github.com/sindresorhus/p-map) - Map over promises concurrently\n- [p-filter](https://github.com/sindresorhus/p-filter) - Filter promises concurrently\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\n---\n\n<div align=\"center\">\n\t<b>\n\t\t<a href=\"https://tidelift.com/subscription/pkg/npm-p-locate?utm_source=npm-p-locate&utm_medium=referral&utm_campaign=readme\">Get professional support for this package with a Tidelift subscription</a>\n\t</b>\n\t<br>\n\t<sub>\n\t\tTidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.\n\t</sub>\n</div>\n","publish_time":1552383984520,"_cnpm_publish_time":1552383984520,"dist-tags":{"latest":"7.0.0"}}