Last active
February 24, 2016 00:06
-
-
Save joshuakfarrar/bcea23290e309690857a 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
| var flags = { | |
| testTransform: (true && true), | |
| another: (true && false) | |
| } | |
| var transforms = { | |
| testTransform: { | |
| apply: flags.testTransform, | |
| function: function(name) { return `${name}!`; } | |
| }, | |
| another: { | |
| apply: flags.another, | |
| function: function(name) { return `xXx${name}`; } | |
| }, | |
| working: { | |
| apply: true, | |
| function: function(name) { return `${name}?`} | |
| } | |
| }; | |
| // any of you code kids: follow along, c'mon. js wit' me now. | |
| var transformed = require('lodash').reduce(transforms, function(result, transform) { | |
| if (transform.apply) { | |
| return (function applyTransformToResult(transform, result) { | |
| return transform(result); | |
| }(transform.function, result)); | |
| } else return result; | |
| }, 'joshua'); | |
| console.log(transformed); // joshua!? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment