{"name":"p-locate","version":"6.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"},"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","locate","find","finder","search","searcher","test","array","collection","iterable","iterator","race","fulfilled","fastest","async","await","promises","bluebird"],"dependencies":{"p-limit":"^4.0.0"},"devDependencies":{"ava":"^3.15.0","delay":"^5.0.0","in-range":"^3.0.0","time-span":"^5.0.0","tsd":"^0.17.0","xo":"^0.44.0"},"gitHead":"1f7712038d6c9de2c197bc2ce43f4dc3456ae7f8","bugs":{"url":"https://github.com/sindresorhus/p-locate/issues"},"homepage":"https://github.com/sindresorhus/p-locate#readme","_id":"p-locate@6.0.0","_nodeVersion":"16.7.0","_npmVersion":"7.20.3","dist":{"integrity":"sha512-wPrq66Llhl7/4AGC6I+cqxT07LhXvWL08LNXz1fENOw0Ap4sRZZ/gZpTTJ5jpurzzzfS2W/Ge9BY3LgLjCShcw==","shasum":"3da9a49d4934b901089dca3302fa65dc5a05c04f","tarball":"http://registry-npm.ywwl.com/p-locate/download/p-locate-6.0.0.tgz","fileCount":5,"unpackedSize":7032,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhJi/7CRA9TVsSAnZWagAAUKQP/2avAZIlJukNci1H89Ln\nyXjHJMAw41/5cxS/oZJvrdFghOc/2rc2xAJ/ZNM2QBUNx2kUJhjkk2uzS3Zi\nNN9mTQpiw4nnuaFc6HRr0kDN9sGVo6Br5w+5BVRAOW7QEqdxRanc6fN9bRnb\nL5Cbe5MNb94in8krKUA0kKsPH3Ari2V2S8c7ZOSmpc2XsCkYFpLXm4ra6eqy\nFZFOD0IdmVPBkdFU/cWW6xjTNzcpLh+BITGbg4Szzch2ro6KIGNJN07By2Rw\nVmiz0xJ5Z72Z126l86K8rc4EUrkaXGCBmfz5ZTjRBhGKPV4Ce699X1xXp7Cc\nDZx3wCWZ3fGm5LZKd919+oThmkbD8kaPqCG77XpnOZO6nevF25thDL5Nch3A\n4WA3zssWjtgmjzbDVDsZZGAExG36h09QpaNC045vJLDAjy8bcCDqz7L9ykKF\niVTsEMcMTuPU0gpVgewpXfdSGu3K8UG3Nxn9YxE/sd0ql9/W0gJyGlAw+IZX\nCXIjum8uJweYFb4/1NuWdZGARlgNCpIaSl5KIxAFqt3UvqmTQ1DvblOnpHOW\n388Km7XF8/a+HQvppbBKgsQWQE0rJRDc4dqbZvIvZlhUzEVmJ4fe6qVHHURf\nKdSEKOM2Pp6jyddQKvp31oJAgsSb6AqY3yTvOjNlNsofb1JElkDt5H2YIm91\nqKhj\r\n=Hbz2\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDyvByQIlyPMoyvtlh6PQsoZNBc0UxhAs44tARHgYW4RQIgD8fNassgG6xy51Mh8eKyneOQApuZ5H51cqdwJ1xbJBg="}],"size":3069,"noattachment":false,"key":"/p-locate/-/p-locate-6.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-locate_6.0.0_1629892603140_0.8482496598470137"},"_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":1629892603294,"_cnpm_publish_time":1629892603294,"dist-tags":{"latest":"7.0.0"}}