@augment-vir/common
Version:
A collection of augments, helpers types, functions, and classes for any JavaScript environment.
18 lines (17 loc) • 760 B
TypeScript
import { type MaybePromise, type Tuple } from '@augment-vir/core';
/**
* Executes the given callback a given count of times.
*
* @category Function
* @category Package : @augment-vir/common
* @example
*
* ```ts
* import {executeCount} from '@augment-vir/common';
*
* executeCount(5, (count) => console.log(count)); // will log: 1,2,3,4,5
* ```
*
* @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common)
*/
export declare function executeCount<N extends number, T = void | undefined>(count: N, callback: (currentCount: number, totalCount: number) => T): Extract<T, Promise<any>> extends never ? Tuple<T, N> : Exclude<T, Promise<any>> extends never ? Promise<Tuple<Awaited<T>, N>> : MaybePromise<Tuple<Awaited<T>, N>>;