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

Housekeeping #23

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

Housekeeping #23

wants to merge 9 commits into from

Conversation

vladimyr
Copy link

This PR brings in following changes:

  • added .editorconfig
  • updated .gitignore, ESLint & Travis CI config
  • removal of npm leftovers - completed migration to yarn
  • upgrade of (dev) dependencies to latest versions
  • refactor of internals (dynamic next callback resolution)

@vladimyr vladimyr mentioned this pull request Nov 20, 2019
Copy link
Owner

@davidbanham davidbanham left a comment

Choose a reason for hiding this comment

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

Looks great in general, thanks! Just have a couple questions on the refactor internals commit.

return Object.keys(source).reduce((acc, key) => {
const value = source[key];
return Object.assign(acc, { [key]: value });
}, dest);
Copy link
Owner

Choose a reason for hiding this comment

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

Can you expand on the reason for this refactor?

Copy link
Author

Choose a reason for hiding this comment

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

I thought reduce serves better purpose conveying message to the reader because source object is reduced (Yeah it is mapped but every mapper is in fact a reducer) to destination one. Plus reduce has return value compared to forEach which I thought is neat and leveraged here.

const originalParam = Router.prototype.constructor.param;
Router.prototype.constructor.param = function param(name, fn) {
fn = wrap(fn);
return originalParam.call(this, name, fn);
Copy link
Owner

Choose a reason for hiding this comment

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

Do we not change the value of this by removing this section from the wrap closure?

Copy link
Author

Choose a reason for hiding this comment

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

Value of this in this case is determined by Router#param callsite and explicitly forwarded to original implementation using .call binding so it is preserved. Moving it out of a function doesn't change 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

Successfully merging this pull request may close these issues.

2 participants