Last active
February 2, 2023 13:48
-
-
Save karol-majewski/e1a53b9abd39f3b7c3f4bf150546168a to your computer and use it in GitHub Desktop.
The simplest flatMap implementation in TypeScript
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 function flatMap<T, U>(array: T[], callbackfn: (value: T, index: number, array: T[]) => U[]): U[] { | |
return Array.prototype.concat(...array.map(callbackfn)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment