Created
February 3, 2021 21:00
-
-
Save AyAyEm/28a08d805e4ef36519d26acaeef64db0 to your computer and use it in GitHub Desktop.
Simple iteration function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function iterate<T>( | |
iterations: number, | |
callback: (iteration: number) => T, | |
): T[] { | |
const result: T[] = Array(iterations).fill(null).map((_value, index) => { | |
return callback(index); | |
}); | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment