CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes48downloads
readme.md94 linesDownload Raw Back to p-locate
1# p-locate [![Build Status](https://travis-ci.com/sindresorhus/p-locate.svg?branch=master)](https://travis-ci.com/github/sindresorhus/p-locate)2 3> Get the first fulfilled promise that satisfies the provided testing function4 5Think of it like an async version of [`Array#find`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/find).6 7## Install8 9```10$ npm install p-locate11```12 13## Usage14 15Here we find the first file that exists on disk, in array order.16 17```js18const pathExists = require('path-exists');19const pLocate = require('p-locate');20 21const files = [22	'unicorn.png',23	'rainbow.png', // Only this one actually exists on disk24	'pony.png'25];26 27(async () => {28	const foundPath = await pLocate(files, file => pathExists(file));29 30	console.log(foundPath);31	//=> 'rainbow'32})();33```34 35*The above is just an example. Use [`locate-path`](https://github.com/sindresorhus/locate-path) if you need this.*36 37## API38 39### pLocate(input, tester, options?)40 41Returns 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`.42 43#### input44 45Type: `Iterable<Promise | unknown>`46 47An iterable of promises/values to test.48 49#### tester(element)50 51Type: `Function`52 53This function will receive resolved values from `input` and is expected to return a `Promise<boolean>` or `boolean`.54 55#### options56 57Type: `object`58 59##### concurrency60 61Type: `number`\62Default: `Infinity`\63Minimum: `1`64 65Number of concurrently pending promises returned by `tester`.66 67##### preserveOrder68 69Type: `boolean`\70Default: `true`71 72Preserve `input` order when searching.73 74Disable this to improve performance if you don't care about the order.75 76## Related77 78- [p-map](https://github.com/sindresorhus/p-map) - Map over promises concurrently79- [p-filter](https://github.com/sindresorhus/p-filter) - Filter promises concurrently80- [p-any](https://github.com/sindresorhus/p-any) - Wait for any promise to be fulfilled81- [More…](https://github.com/sindresorhus/promise-fun)82 83---84 85<div align="center">86	<b>87		<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>88	</b>89	<br>90	<sub>91		Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.92	</sub>93</div>94 
basant307/AI_Governance_Project · CoolFace