Skip to content

Instantly share code, notes, and snippets.

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