UNPKG

@augment-vir/common

Version:

A collection of augments, helpers types, functions, and classes for any JavaScript environment.

35 lines (34 loc) 933 B
import { awaitedBlockingMap } from './awaited-map.js'; /** * Performs * [`[].forEach()`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach) * on an array but supports an async callback. The async callback is blocking. Meaning, * `awaitedForEach` will wait for a callback on array element 1 to finish before moving on to array * element 2. * * @category Array * @category Package : @augment-vir/common * @example * * ```ts * import {awaitedForEach} from '@augment-vir/common'; * * await awaitedForEach( * [ * 1, * 2, * 3, * 4, * 5, * ], * async (value) => { * await Promise.resolve(value); * }, * ); * ``` * * @package [`@augment-vir/common`](https://www.npmjs.com/package/@augment-vir/common) */ export async function awaitedForEach(input, callback) { await awaitedBlockingMap(input, callback); }