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

optimize partial and partialRight to correctly process rest args #2941

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

adispring
Copy link
Member

@adispring adispring commented Dec 22, 2019

@CrossEye Optimize partial and partialRight as you suggested.

related to #2940

Copy link
Member

@CrossEye CrossEye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this change overall, but we need to change the test. I think the one from #2940 that brought this on would be a fine test. We shouldn't really care what happens with the remaining parameters.

var foo = (a, b, c, d, ...rest) => ({ a, b, c, d, rest });
var f = R.partial(foo, [100, 200]);
eq(f(1, 2, 3, 4), { a: 100, b: 200, c: 1, d: 2, rest: [3, 4] });
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So long as we're supporting ES5, I don't think we can include this test.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So how should I modify the test, should these test files stay as before?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should remove the tests for ...rest and add one for the version of greet that inspired #2940. That should show the behavior well enough.

Copy link
Member Author

@adispring adispring Dec 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this way?:

const greet = (salutation, title, firstName, lastName) =>
  salutation + ', ' + title + ' ' + firstName + ' ' + lastName + '!';

const greetMsJaneJones = R.partialRight(greet, ['Ms.', 'Jane', 'Jones']);

greetMsJaneJones('Hello', 'Mr.' 'Green'); //=> 'Hello, Ms. Jane Jones!'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exactly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has changed the test as you suggested.

var foo = (a, b, c, d, ...rest) => ({ a, b, c, d, rest });
var f = R.partialRight(foo, [100, 200]);
eq(f(1, 2, 3, 4), { a: 1, b: 2, c: 100, d: 200, rest: [3, 4] });
});
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

CrossEye
CrossEye previously approved these changes Dec 26, 2019
@CrossEye
Copy link
Member

This looks good to me. Others? @ramda/core?

@CrossEye CrossEye added the resolve-conflicts PR needs to be updated due to conflicts before merging label Jan 23, 2022
@CrossEye
Copy link
Member

@adispring: Another issue that's been dropped. This should go in. Could you resolve the conflicts with the current HEAD?

@adispring
Copy link
Member Author

Ok, I will resolve the conflict soon.

@adispring adispring force-pushed the optimize-partial-partialRight branch from 4a7c9ac to 0987d0a Compare January 25, 2022 01:42
@adispring
Copy link
Member Author

The conflict has been resolved.

Copy link
Member

@customcommander customcommander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
resolve-conflicts PR needs to be updated due to conflicts before merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants