-
Notifications
You must be signed in to change notification settings - Fork 3k
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
fix(pipe): Special handling for 0-arg case. #4936
Conversation
The right predictable behavior may be to throw an error. The sum of an
empty collection of numbers is 0, but what is the sum of a null of numbers?
… |
I'm fine with it throwing an error. I just don't think it should return a no-op. Given that the type signature requires an array to be passed, I think removing the entire |
The check is never reached in internal code, and is not exported for external code. The behavior is not tested for, and arguably wrong.
Removed the check for nonexistent array argument. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Oh, I see, we wanted to keep the error on the |
* fix(pipe): Special handling for 0 args. * test(pipe): Fix test label for 0-arg. * fix(pipe): Remove check for missing args array. The check is never reached in internal code, and is not exported for external code. The behavior is not tested for, and arguably wrong. * fix(pipe): no argument case run-time check * refactor: revert checking for lack of array argument Co-authored-by: Ben Lesh <ben@benlesh.com>
Optimize calling
pipe
with 0 args.Closes #4933
There is an
if (!fns)
check in thepipeFromArray
helper, and it results innoop
. The test forpipe
says the 0-arg case returns a no-op, but it checks foridentity
. The test is probably meant to test for that check, but the check is for the lack of an args array, so I added a check for that test to test and fixed the test's label.The
if (!fns)
check might not be necessary at all. It is unreachable from client code, sincepipeFromArray
is internal, and is only used frompipe
, which will never pass null/undefined.