-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add compose function #30
Conversation
Missing docblock & tests.
Hey your logic is definitely sound, but I think I didn't provide you enough info in my last comment. Also, out of curiosity - have you used compose in any of your applications? |
Sorry, you did say that in the comments. I submitted a version which matched my usage patterns. I'm using To your point about solving needs from your apps (and |
if var compose = require('101/compose');
var composed = [f, g, h, i, j, k, l].reduceRight(compose);
// composed(x) === f(g(h(i(j(k(l(x))))))) // true
// assuming: compose(f, g)(x) === f(g(x)) // true What do you think? |
I think it's great. This is what you described from the beginning and it works well. I'll submit the tests in a separate commit. In my projects, I'll likely add something like:
because I don't think it's apparent that Thanks for the example and persistence. I'm glad to know the binary |
Cool, I'm glad you agree. I can definitely see how it isn't immediately apparent, especially upon seeing this type of behavior for the first time. Because of this we should definitely put that in the Readme as an example, I think that will be enough to clear up the confusion. If more people ask for this behavior, I will definitely consider adding it. I just want to keep things barebones for as long as I can, or this library might start getting bloated like others. |
Thanks for the help! 👍 |
Btw I think I made a mistake it is just var compose = require('101/compose');
var composed = [f, g, h, i, j, k, l].reduce(compose);
// composed(x) === f(g(h(i(j(k(l(x))))))) // true
// assuming: compose(f, g)(x) === f(g(x)) // true Also, would love some tests for this. I am trying to maintain 100% test coverage for 101. |
* 'master' of https://github.com/jfsiii/101: Accept 2 functions, return the composed function
Fantastic! Thank you! |
It's missing the docblock & tests but I wanted to get feedback before I submitted the left-to-right version