Array map with
Async
callback function.
Syntax
aMap(
arr: T[],
cb: (value: T, index: number) => Promise<unknown>
): Promise<unknown[]>
Usage
import { aMap } from "@opentf/std";
aMap([], async (value, index) => {});
Examples
const arr = [1, 2, 3, 4, 5];
function multiply(n, i) {
return new Promise((resolve) => {
resolve(n * i);
});
}
const result = await aMap(arr, async (n, i) => await multiply(n, i));
console.log(result); // [0, 2, 6, 12, 20]