Skip to content

Instantly share code, notes, and snippets.

@AyAyEm
Created February 3, 2021 21:00
Show Gist options
  • Save AyAyEm/28a08d805e4ef36519d26acaeef64db0 to your computer and use it in GitHub Desktop.
Save AyAyEm/28a08d805e4ef36519d26acaeef64db0 to your computer and use it in GitHub Desktop.
Simple iteration function
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