Last active
October 21, 2020 08:11
-
-
Save marlun78/c1ce2b00187808884f49fb6f368daaa0 to your computer and use it in GitHub Desktop.
TypeScript flatMap
This file contains hidden or 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
export const flatMap = <T, U>( | |
array: T[], | |
callback: (value: T, index: number, array: T[]) => U | |
): U[] => { | |
return Array.prototype.concat(...array.map(callback)); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment