Created
April 10, 2019 22:41
-
-
Save emaphp/1f63e27d75bcd2de9b0476193e2b27cb to your computer and use it in GitHub Desktop.
transform + reduce
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
| function readPosX(stream, acc) { | |
| let val = stream.substr(0, 2); | |
| acc.posX = val; | |
| return stream.substr(2); | |
| } | |
| function readPosY(stream, acc) { | |
| let val = stream.substr(0, 2); | |
| acc.posY = val; | |
| return stream.substr(2); | |
| } | |
| var transformations = [readPosX, readPosY]; | |
| var stream = 'abcdef'; | |
| var data = {}; | |
| transformations.forEach(func => { | |
| stream = func(stream, data); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment