Created
July 26, 2020 10:17
-
-
Save jmaicaaan/98a28a5f94afd99794fe465f82e163d6 to your computer and use it in GitHub Desktop.
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
// non-fusion approach | |
const data = [ | |
1, | |
2, | |
3, | |
4, | |
5, | |
]; | |
const add = (x) => x + 1; | |
const multiplyBy2 = (x) => x * 2; | |
const res = data | |
.map((i) => { | |
console.log('add mapper'); // called 5 times | |
const sum = add(i); | |
const product = multiplyBy2(sum); | |
return product; | |
}) | |
// [ 4, 6, 8, 10, 12 ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment