CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes48downloads
index.d.ts54 linesDownload Raw Back to p-locate
1declare namespace pLocate {2	interface Options {3		/**4		Number of concurrently pending promises returned by `tester`. Minimum: `1`.5 6		@default Infinity7		*/8		readonly concurrency?: number;9 10		/**11		Preserve `input` order when searching.12 13		Disable this to improve performance if you don't care about the order.14 15		@default true16		*/17		readonly preserveOrder?: boolean;18	}19}20 21/**22Get the first fulfilled promise that satisfies the provided testing function.23 24@param input - An iterable of promises/values to test.25@param tester - This function will receive resolved values from `input` and is expected to return a `Promise<boolean>` or `boolean`.26@returns 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`.27 28@example29```30import pathExists = require('path-exists');31import pLocate = require('p-locate');32 33const files = [34	'unicorn.png',35	'rainbow.png', // Only this one actually exists on disk36	'pony.png'37];38 39(async () => {40	const foundPath = await pLocate(files, file => pathExists(file));41 42	console.log(foundPath);43	//=> 'rainbow'44})();45```46*/47declare function pLocate<ValueType>(48	input: Iterable<PromiseLike<ValueType> | ValueType>,49	tester: (element: ValueType) => PromiseLike<boolean> | boolean,50	options?: pLocate.Options51): Promise<ValueType | undefined>;52 53export = pLocate;54 
basant307/AI_Governance_Project · CoolFace