Skip to content

optimize partial and partialRight to correctly process rest args#2941

Open
adispring wants to merge 3 commits into
ramda:masterfrom
adispring:optimize-partial-partialRight
Open

optimize partial and partialRight to correctly process rest args#2941
adispring wants to merge 3 commits into
ramda:masterfrom
adispring:optimize-partial-partialRight

Conversation

@adispring
Copy link
Copy Markdown
Member

@adispring adispring commented Dec 22, 2019

@CrossEye Optimize partial and partialRight as you suggested.

related to #2940

Copy link
Copy Markdown
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.

Comment thread test/partial.js
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

Choose a reason for hiding this comment

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

exactly.

Copy link
Copy Markdown
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.

Comment thread test/partialRight.js
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

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

@adispring
Copy link
Copy Markdown
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
Copy Markdown
Member Author

The conflict has been resolved.

@customcommander customcommander self-requested a review January 25, 2022 09:12
Copy link
Copy Markdown
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.

3 participants