{"_id":"p-locate","_rev":"632628","name":"p-locate","description":"Get the first fulfilled promise that satisfies the provided testing function","dist-tags":{"latest":"6.0.0"},"maintainers":[{"name":"sindresorhus","email":""}],"time":{"modified":"2021-08-25T12:00:48.000Z","created":"2016-11-20T10:07:34.210Z","6.0.0":"2021-08-25T11:56:43.294Z","5.0.0":"2020-08-10T17:42:34.692Z","4.1.0":"2019-04-04T05:02:46.111Z","4.0.0":"2019-03-12T09:46:24.520Z","3.0.0":"2018-06-15T12:47:57.897Z","2.0.0":"2016-11-28T05:25:21.460Z","1.0.0":"2016-11-20T10:07:34.210Z"},"users":{"rocket0191":true},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-locate.git"},"versions":{"6.0.0":{"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":{"shasum":"3da9a49d4934b901089dca3302fa65dc5a05c04f","size":3069,"noattachment":false,"key":"/p-locate/-/p-locate-6.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-locate/download/p-locate-6.0.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-locate_6.0.0_1629892603140_0.8482496598470137"},"_hasShrinkwrap":false,"publish_time":1629892603294,"_cnpm_publish_time":1629892603294},"5.0.0":{"name":"p-locate","version":"5.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"},"engines":{"node":">=10"},"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":"^3.0.2"},"devDependencies":{"ava":"^2.4.0","delay":"^4.1.0","in-range":"^2.0.0","time-span":"^4.0.0","tsd":"^0.13.1","xo":"^0.32.1"},"gitHead":"a01d0e4d555c00e1551954751fd3cd4b238ce82f","bugs":{"url":"https://github.com/sindresorhus/p-locate/issues"},"homepage":"https://github.com/sindresorhus/p-locate#readme","_id":"p-locate@5.0.0","_nodeVersion":"14.5.0","_npmVersion":"6.14.7","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"83c8315c6785005e3bd021839411c9e110e6d834","size":3151,"noattachment":false,"key":"/p-locate/-/p-locate-5.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-locate/download/p-locate-5.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-locate_5.0.0_1597081354525_0.2940768154089548"},"_hasShrinkwrap":false,"publish_time":1597081354692,"_cnpm_publish_time":1597081354692},"4.1.0":{"name":"p-locate","version":"4.1.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"},"keywords":["promise","locate","find","finder","search","searcher","test","array","collection","iterable","iterator","race","fulfilled","fastest","async","await","promises","bluebird"],"dependencies":{"p-limit":"^2.2.0"},"devDependencies":{"ava":"^1.4.1","delay":"^4.1.0","in-range":"^1.0.0","time-span":"^3.0.0","tsd":"^0.7.2","xo":"^0.24.0"},"gitHead":"a650b26e49713a8cca58f669a7f8aef9b655554c","bugs":{"url":"https://github.com/sindresorhus/p-locate/issues"},"homepage":"https://github.com/sindresorhus/p-locate#readme","_id":"p-locate@4.1.0","_nodeVersion":"8.15.0","_npmVersion":"6.9.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"a3428bb7088b3a60292f66919278b7c297ad4f07","size":3060,"noattachment":false,"key":"/p-locate/-/p-locate-4.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-locate/download/p-locate-4.1.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-locate_4.1.0_1554354165996_0.6426620981467144"},"_hasShrinkwrap":false,"publish_time":1554354166111,"_cnpm_publish_time":1554354166111},"4.0.0":{"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":{"shasum":"fff5d4a5dc4f89babe7d266f6efc685630038651","size":2916,"noattachment":false,"key":"/p-locate/-/p-locate-4.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-locate/download/p-locate-4.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-locate_4.0.0_1552383984361_0.08899244113594595"},"_hasShrinkwrap":false,"publish_time":1552383984520,"_cnpm_publish_time":1552383984520},"3.0.0":{"name":"p-locate","version":"3.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":">=6"},"scripts":{"test":"xo && ava"},"files":["index.js"],"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":"*","delay":"^3.0.0","in-range":"^1.0.0","time-span":"^2.0.0","xo":"*"},"gitHead":"d37f108c0b04779e307b4e7203981caa367bac57","bugs":{"url":"https://github.com/sindresorhus/p-locate/issues"},"homepage":"https://github.com/sindresorhus/p-locate#readme","_id":"p-locate@3.0.0","_npmVersion":"5.6.0","_nodeVersion":"8.11.2","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"322d69a05c0264b25997d9f40cd8a891ab0064a4","size":2579,"noattachment":false,"key":"/p-locate/-/p-locate-3.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-locate/download/p-locate-3.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/p-locate_3.0.0_1529066877849_0.3762033584213962"},"_hasShrinkwrap":false,"publish_time":1529066877897,"_cnpm_publish_time":1529066877897},"2.0.0":{"name":"p-locate","version":"2.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":">=4"},"scripts":{"test":"xo && ava"},"files":["index.js"],"keywords":["promise","locate","find","finder","search","searcher","test","array","collection","iterable","iterator","race","fulfilled","fastest","async","await","promises","bluebird"],"dependencies":{"p-limit":"^1.1.0"},"devDependencies":{"ava":"*","delay":"^1.3.1","in-range":"^1.0.0","time-span":"^1.0.0","xo":"*"},"xo":{"esnext":true},"gitHead":"6300abb6451f04bbaa760f42844ec1c501d79120","bugs":{"url":"https://github.com/sindresorhus/p-locate/issues"},"homepage":"https://github.com/sindresorhus/p-locate#readme","_id":"p-locate@2.0.0","_shasum":"20a0103b222a70c8fd39cc2e580680f3dde5ec43","_from":".","_npmVersion":"3.10.9","_nodeVersion":"7.2.0","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"20a0103b222a70c8fd39cc2e580680f3dde5ec43","size":2580,"noattachment":false,"key":"/p-locate/-/p-locate-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-locate/download/p-locate-2.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/p-locate-2.0.0.tgz_1480310721089_0.044998719124123454"},"directories":{},"publish_time":1480310721460,"_cnpm_publish_time":1480310721460,"_hasShrinkwrap":false},"1.0.0":{"name":"p-locate","version":"1.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":">=4"},"scripts":{"test":"xo && ava"},"files":["index.js"],"keywords":["promise","locate","find","finder","search","searcher","test","array","collection","iterable","iterator","race","fulfilled","fastest","async","await","promises","bluebird"],"dependencies":{"p-map":"^1.1.0"},"devDependencies":{"ava":"*","delay":"^1.3.1","in-range":"^1.0.0","time-span":"^1.0.0","xo":"*"},"xo":{"esnext":true},"gitHead":"3950c4990ccb06fd7846255fa8570dda3efaa153","bugs":{"url":"https://github.com/sindresorhus/p-locate/issues"},"homepage":"https://github.com/sindresorhus/p-locate#readme","_id":"p-locate@1.0.0","_shasum":"0741476fe43666849508fd0b125778982de716aa","_from":".","_npmVersion":"2.15.11","_nodeVersion":"4.6.2","_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"dist":{"shasum":"0741476fe43666849508fd0b125778982de716aa","size":2303,"noattachment":false,"key":"/p-locate/-/p-locate-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/p-locate/download/p-locate-1.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/p-locate-1.0.0.tgz_1479636453993_0.39431346161291003"},"directories":{},"publish_time":1479636454210,"_cnpm_publish_time":1479636454210,"_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","_attachments":{},"homepage":"https://github.com/sindresorhus/p-locate#readme","bugs":{"url":"https://github.com/sindresorhus/p-locate/issues"},"license":"MIT"}