tjmehta / 101

A modern JS utility library
MIT License
1.55k stars 75 forks source link

Infinite Compose #133

Closed thejsj closed 8 years ago

thejsj commented 8 years ago

It's be awesome if compose took an unlimited amount of arguments. Is there a reason this is not the case? (Could help out with a PR if no one objects) @tjmehta

$ node
> var compose = require('101/compose')
undefined
> var plusOne = (x) => x + 1
undefined
> compose(plusOne, plusOne, plusOne)(1)
3
> compose(plusOne, plusOne, plusOne, plusOne)(1)
3
tjmehta commented 8 years ago

So far I've designed methods like 'compose' to work with two args so that they work with 'Array.reduce'. I am not opposed to making it work with infinite args, however I would like it to continue working with 'reduce'. If 'reduce' works for you for now, let's close this off. If someone submits a PR that makes it work both ways I will accept it.

dolsem commented 5 years ago

@tjmehta I'm a bit confused, in your reply you said that you'd be willing to look at a PR, but more than a year before you wrote that you declined #56, which seems to make it work both ways. So is this functionality welcome or not?

tjmehta commented 5 years ago

TBH a year later, I probably didn't remember somebody already tried to add this, and I don't feel strongly about either way..

tjmehta commented 5 years ago

Maybe I thought since two ppl had suggested the same thing it was worth revisiting the idea 🤷‍♂️