{ "_id": "p-locate", "_rev": "7-bc370f2549965c33877f9ea698798304", "name": "p-locate", "description": "Get the first fulfilled promise that satisfies the provided testing function", "dist-tags": { "latest": "5.0.0" }, "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": "https://registry.npmjs.org/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": "https://registry.npmjs.org/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": {} }, "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": { "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", "shasum": "322d69a05c0264b25997d9f40cd8a891ab0064a4", "tarball": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", "fileCount": 4, "unpackedSize": 5055, "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbI7V+CRA9TVsSAnZWagAAmS8P/iJ5wzoShdXBVPfoNY1O\nr0t03ZiQkJ9Ae4XuJU5C5c2Si7lcgGw8sx6C+iAcYX/zWv7mfygNi+C/ADF5\nZuCBwp0hhC2Nott55961FfTiCHTO2/MRApZo2Eg3sl/ru0KglHvRFS5r/ZXb\n634s++vlPvlbFzCDfELeeM8YOxNjYryRhgNQ6UxXIvsU8RffnrMDXVJphnXE\nWuUEmhgCxzSgH8F/C0DblXoAGkp1qwKAY8MmaWgJpvtIvn2JYC/87S3pdSYy\nMngjVE1MTEulUubGKDmO83N1vM45n1r/pMZarNF2GHynO6SWR68JBPIQ+dmn\nFP4iNv+2eJVExkQzg/DKWNwoPSmq3karaEBU6AJtHRxoe8qgxdjPgjMqPZ0a\n5KieVHs/rwPxKL2/qOSfElcZ5lrnXICuoErKMeR5NjYD5o1Q+7DUhwAWzATv\nS7vP0ZdUCS0+Zt/F7vFk24WzOAhiGNK/aL5TtfKYGu9VmBDj1gJNOVHP+/zl\nRWjSFB9rkVoCYxscx+VYERfgAHqldYF2afgTNOVHy0iNOFelldi1oCT3KP0W\nIMyP1lQE+Nz3Z7JdrFIhe+a2N+swjaadfCw2nk2mesCBvYZDNUeTlQ9ao05h\nFHV0pcoqg98mHz3sklz8aj1phUPkIbbzYd9KPMRAobdjvbtwTQDu2hjYsDXv\niPPm\r\n=9PP9\r\n-----END PGP SIGNATURE-----\r\n" }, "maintainers": [ { "name": "sindresorhus", "email": "sindresorhus@gmail.com" } ], "directories": {}, "_npmOperationalInternal": { "host": "s3://npm-registry-packages", "tmp": "tmp/p-locate_3.0.0_1529066877849_0.3762033584213962" }, "_hasShrinkwrap": false }, "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": { "integrity": "sha512-IvOiDT1hbCdrsFKKXs8AGjxouEfn9VVdz/edtT08IDr+RIn2U/o3Xx+Agx455+CkSRdomMs3EN5BgR2Q0LZX0g==", "shasum": "fff5d4a5dc4f89babe7d266f6efc685630038651", "tarball": "https://registry.npmjs.org/p-locate/-/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" }, "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 }, "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": { "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", "shasum": "a3428bb7088b3a60292f66919278b7c297ad4f07", "tarball": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", "fileCount": 5, "unpackedSize": 7285, "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcpY/2CRA9TVsSAnZWagAALQMP/3vN0BSJiCM4ZVUWhqjQ\nL3PQu0gcZuncKRGoX4Vpm7nhfubo13PwinE5dDOrueBPoCrdYJQk/uuYBJQS\nugePB/oxbLwK1vL0ZanyaJTRYWrdNJsZmciYRkQ09Pci/oyZ39c6sjtkGj7v\nU8dLhR47iNBHf5RhOlxlEGEaxAHIn7xumDwRnK+xDOZCVJp4HmHcT0XK8J08\ncuraQ3ZDCGDFSJUzoL9XGUhFWlxwLfLsHwcjfBfD7kGdLBchlgrgN1uVIa0m\n8ta73mV2JtzYxrRE2WmDyDqfVdNAE0pSoUrTRrGKVrI60TguIv5c+AhEVR+R\nVYl8gnq0FbesgxhYRHz8h64HfArEBkzrOdDFNARBwZh0HYIxLIEO1gzyBKj4\nfGiyMVXKeAiGrxUWfD47Bra9fCQlxjO2IkA7c4PqWj9Al8C6Q2DfGp6e73JP\n3bXxOTNMQVxAjI/Xej7XEHaAB500KvEmrXv4Mz+wyIT3c8pdpwv8MJtw1PLf\naP1iItAWF2FZl5pyxcX9PRGLkIRz452ncq30ZLRbPohdg8+Lcqrq6zeqAucH\nkmY37n1qWmvT9btNTcHz/TsO658ty+3aiZeXh6Aw9V7SvKfxECVWs2t6rtaU\nojg73RJjxBFDr8eju0DuRXJv2EdFoHe/IgymO+eFXk9K7sw3B1RjMzlwt4Ag\nQLSM\r\n=XPFA\r\n-----END PGP SIGNATURE-----\r\n" }, "maintainers": [ { "name": "sindresorhus", "email": "sindresorhus@gmail.com" } ], "directories": {}, "_npmOperationalInternal": { "host": "s3://npm-registry-packages", "tmp": "tmp/p-locate_4.1.0_1554354165996_0.6426620981467144" }, "_hasShrinkwrap": false }, "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": { "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", "shasum": "83c8315c6785005e3bd021839411c9e110e6d834", "tarball": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", "fileCount": 5, "unpackedSize": 7240, "npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfMYcLCRA9TVsSAnZWagAA0EMP/2sNFaf2lQPq5xga4ji+\nqKq31XYNUP1iUqvoKu+6AH93vlKmtciKMb6Fb4pSK2QRaJZ8erwXEKF4XB4V\nqJFOx2U8yNWVg+QoFxBDDVPcfX6tLufro+1n4BittC+pdEG0xfp+e56wV4CH\ncgQjGcLj4cawNBf2cDB/ru9a5GOr7/d1EM2Z2Ya5FCH6nf0PQek2fGxpncsE\nReT5HwG9Hyb2jEW6zCow6vSLLjUuq5MEVaRPOQL13bbovmsF5gaJ2uyibe3r\nFOwF+Lj4i2PT5/GV1wP5PX39dOXvyTSPCohDDmwNKqtPKSUZ52XSixDEwND5\ngn/eXr8e5I3kE8CX1kv2epqZjvOxxS2yoccAAiVkxI3liHy0JpwK4VSL6Fko\nYSRu5tGg8x7TLsZkVukOdWEXV6ys0HyS1rmznUo0ewLP3M4kVNpEuWCNq7W0\nNyNwCmTN4/a1rQsrXw49c9DYbbbqfXy723RTaWD+Z/AH/04wFL9pjRoV+hgl\nw42Hb1ITUjzM2lfiNlLJt0Wzqm2a2WrrUXJ+GfkcsgUFg92Bzqk7K7UYW2SO\nXcRnTaqh1pj2CCgEA61a8VM+UXVA+ZEjgYumaa5zJ6BP0x+h0oWNfB8XBlba\nIYhYx87PUI549RKN+Si/F5vJfWUNOy/O7BEQ/Vhj494POXwMuBkxnuqfLrN2\nDFey\r\n=zCT1\r\n-----END PGP SIGNATURE-----\r\n" }, "maintainers": [ { "name": "sindresorhus", "email": "sindresorhus@gmail.com" } ], "directories": {}, "_npmOperationalInternal": { "host": "s3://npm-registry-packages", "tmp": "tmp/p-locate_5.0.0_1597081354525_0.2940768154089548" }, "_hasShrinkwrap": false } }, "readme": "# p-locate [![Build Status](https://travis-ci.com/sindresorhus/p-locate.svg?branch=master)](https://travis-ci.com/github/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## 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\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\n(async () => {\n\tconst foundPath = await pLocate(files, file => pathExists(file));\n\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## 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`\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` or `boolean`.\n\n#### options\n\nType: `object`\n\n##### concurrency\n\nType: `number`\\\nDefault: `Infinity`\\\nMinimum: `1`\n\nNumber 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
\n\t\n\t\tGet professional support for this package with a Tidelift subscription\n\t\n\t
\n\t\n\t\tTidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.\n\t
\n
\n", "maintainers": [ { "name": "sindresorhus", "email": "sindresorhus@gmail.com" } ], "time": { "modified": "2020-08-10T17:42:37.057Z", "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", "3.0.0": "2018-06-15T12:47:57.897Z", "4.0.0": "2019-03-12T09:46:24.520Z", "4.1.0": "2019-04-04T05:02:46.111Z", "5.0.0": "2020-08-10T17:42:34.692Z" }, "homepage": "https://github.com/sindresorhus/p-locate#readme", "keywords": [ "promise", "locate", "find", "finder", "search", "searcher", "test", "array", "collection", "iterable", "iterator", "race", "fulfilled", "fastest", "async", "await", "promises", "bluebird" ], "repository": { "type": "git", "url": "git+https://github.com/sindresorhus/p-locate.git" }, "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "https://sindresorhus.com" }, "bugs": { "url": "https://github.com/sindresorhus/p-locate/issues" }, "license": "MIT", "readmeFilename": "readme.md", "users": { "rocket0191": true } }