Created
January 15, 2019 14:45
-
-
Save mfrachet/a91fc4d61c78d5cc5b87552b0d963768 to your computer and use it in GitHub Desktop.
ningo-transduce.js
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
import transduce from "ningo/transduce"; | |
const data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; | |
const isEven = x => x % 2 === 0; | |
const double = x => x * 2; | |
const doubleEven = transduce() | |
.map(double) // runs second | |
.filter(isEven); // runs first | |
const newArray = doubleEven.run(data); | |
console.log(newArray); // [ 4, 8, 12, 16, 20 ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment