A new array filled with the results of the given callback typed as a Tuple,
automatically wrapping the return type in a Promise if the callback returns one.
import {createArray} from '@augment-vir/common';
const result = createArray(5, (index) => {
return `hi ${index}`;
});
// result is `['hi 0', 'hi 1', 'hi 2', 'hi 3', 'hi 4']`
const asyncResult = await createArray(5, async (index) => {
return Promise.resolve(`hi ${index}`);
});
// result is `['hi 0', 'hi 1', 'hi 2', 'hi 3', 'hi 4']`
Creates an array of size
sizeand calls the givencallbackfor each entry in the array and fills the array with the results. The returned array is typed to exactly fit the given size.This function automatically awaits async callbacks.