Skip to content

Instantly share code, notes, and snippets.

@jmaicaaan
Created July 26, 2020 09:58
Show Gist options
  • Save jmaicaaan/c0897cf2b49d897ddf2d6d1afcaf025b to your computer and use it in GitHub Desktop.
Save jmaicaaan/c0897cf2b49d897ddf2d6d1afcaf025b to your computer and use it in GitHub Desktop.
// 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