Skip to content
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

QQ.step can accept array of funtions #4

Open
veged opened this issue Apr 1, 2012 · 3 comments
Open

QQ.step can accept array of funtions #4

veged opened this issue Apr 1, 2012 · 3 comments

Comments

@veged
Copy link

veged commented Apr 1, 2012

If first argument of QQ.step is Array (or not Function) it was be useful use it instead all arguments.
Now I should write QQ.step.apply(Q, [ f1, f2 ]) instead of QQ.step([ f1, f2 ]).

Also Q.all can opposite accept multiply arguments in conjunction with Array: Q.all([ ... ]) ~ Q.all(..., ..., ...).

@kriskowal
Copy link
Owner

I am pretty adamant about not mixing variadic and array signatures because of the ambiguity of a single array argument. I shy in general from variadic functions because it’s such a pain to spread an array into arguments. Could I interest you in this shorthand instead?

[f1, f2].reduce(Q.when, Q.resolve())

@veged
Copy link
Author

veged commented Apr 2, 2012

But in case of QQ.step there is no ambiguity with a single array argument, because all arguments must be functions.

If you so adamant about such polymorphism for functions, maybe you can add another function for this purposes (arrStep or something)? [f1, f2].reduce(Q.when, Q.resolve()) not so shorthand even in comparison with QQ.step.apply(Q, [ f1, f2 ]).

@kriskowal
Copy link
Owner

@veged Good point about the brevity of the shorthand.

I would entertain changing the signature of QQ.step to accept an array instead of variadic arguments in a future backward-incompatible version. I might even remove Q.deep which would mean that each function would have to return a promise. There was an earlier problem where an object that contains a buffer would seriously slow the system down, since Q.deep would check every byte for a promise. It is probably better not to use Q.deep at all in hindsight.

All thoughts welcome. This library belongs to the people using it and I have very little agenda for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants