UNPKG

data-fns

Version:

This library provides utility functions for working with array data that are useful in many contexts, including creative coding. It offers generic functions that perform common operations such as offsetting an array, generating an array based on a callbac

12 lines (11 loc) 474 B
/** * Calls a callback function a specified number of times and returns the results in an array. * @param iterations The number of times to call the callback function. * @param callback The callback function to call. * @returns An array containing the results of each callback function call. * @example * times(5, (i) => i * 2) * // Returns [0, 2, 4, 6, 8] * */ export declare const times: <T>(iterations: number, callback: (index: number) => T) => T[];