{"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"keywords":["promise","locate","find","finder","search","searcher","test","array","collection","iterable","iterator","race","fulfilled","fastest","async","await","promises","bluebird"],"dist-tags":{"latest":"2.0.0"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"sindresorhus.com"},"description":"Get the first fulfilled promise that satisfies the provided testing function","readme":"# p-locate [![Build Status](https://travis-ci.org/sindresorhus/p-locate.svg?branch=master)](https://travis-ci.org/sindresorhus/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\n## Install\n\n```\n$ npm install --save p-locate\n```\n\n\n## Usage\n\nHere we find the first file that exists on disk, in array order.\n\n```js\nconst pathExists = require('path-exists');\nconst pLocate = require('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\npLocate(files, file => pathExists(file)).then(foundPath => {\n\tconsole.log(foundPath);\n\t//=> 'rainbow'\n});\n```\n\n*The above is just an example. Use [`locate-path`](https://github.com/sindresorhus/locate-path) if you need this.*\n\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|any>`\n\n#### tester(element)\n\nType: `Function`\n\nExpected to return a `Promise<boolean>` or boolean.\n\n#### options\n\nType: `Object`\n\n##### concurrency\n\nType: `number`<br>\nDefault: `Infinity`<br>\nMinimum: `1`\n\nNumber of concurrently pending promises returned by `tester`.\n\n##### preserveOrder\n\nType: `boolean`<br>\nDefault: `true`\n\nPreserve `input` order when searching.\n\nDisable this to improve performance if you don't care about the order.\n\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## License\n\nMIT © [Sindre Sorhus](https://sindresorhus.com)\n","repository":{"type":"git","url":"git+https://github.com/sindresorhus/p-locate.git"},"bugs":{"url":"https://github.com/sindresorhus/p-locate/issues"},"license":"MIT","versions":{"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","tarball":"http://nexus.dui88.com:8081/nexus/content/groups/npm-all/p-locate/-/p-locate-1.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/p-locate-1.0.0.tgz_1479636453993_0.39431346161291003"},"directories":{}},"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","tarball":"http://nexus.dui88.com:8081/nexus/content/groups/npm-all/p-locate/-/p-locate-2.0.0.tgz"},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/p-locate-2.0.0.tgz_1480310721089_0.044998719124123454"},"directories":{}}},"name":"p-locate","time":{"modified":"2016-11-28T05:25:21.460Z","created":"2016-11-20T10:07:34.210Z","1.0.0":"2016-11-20T10:07:34.210Z","2.0.0":"2016-11-28T05:25:21.460Z"},"readmeFilename":"readme.md","homepage":"https://github.com/sindresorhus/p-locate#readme"}