Created
July 26, 2020 09:58
-
-
Save jmaicaaan/c0897cf2b49d897ddf2d6d1afcaf025b 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 | |
return add(i); | |
}) | |
.map((i) => { | |
console.log('multiplyBy2 mapper'); // called 5 times | |
return multiplyBy2(i); | |
}) | |
// [ 4, 6, 8, 10, 12 ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment