Created
February 6, 2020 20:03
-
-
Save tincho/a44c336a033105f21b7a1aa7b1a791dd to your computer and use it in GitHub Desktop.
This file contains 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
// @params: N functions that should return an Object | |
// @returns a fn that will pass all arg to all fns and return an Obj with all outputs merged | |
const mergeOutputs = (...fns) => (...args) => fns.reduce((out, fn) => ({ | |
...out, | |
...fn(...args) | |
}), {}) | |
// takes one arg | |
const one = (name) => ({ hello: name, world: name }) | |
// takes two arg | |
const two = (name, lastname) => ({ fullName: `${name} ${lastname}` }) | |
const objectMaker = mergeOutputs(one,two) | |
console.log(objectMaker('martin', 'salinas')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment