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

Use Object.assign instead of lodash merge #970

Merged
merged 2 commits into from
Jul 13, 2019
Merged

Use Object.assign instead of lodash merge #970

merged 2 commits into from
Jul 13, 2019

Conversation

stevenjoezhang
Copy link
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our guidelines.
  • Tests for the changes was maked (for bug fixes / features).
    • Muse | Mist have been tested.
    • Pisces | Gemini have been tested.
  • Docs in NexT website have been added / updated (for features).

PR Type

What kind of change does this PR introduce?

  • Bugfix.
  • Feature.
  • Code style update (formatting, local variables).
  • Refactoring (no functional changes, no api changes).
  • Build related changes.
  • CI related changes.
  • Documentation content changes.
  • Other... Please describe:

What is the current behavior?

Issue resolved: N/A

What is the new behavior?

  • Screenshots with this changes: N/A
  • Link to demo site with this changes: N/A

How to use?

In NexT _config.yml:

...

Does this PR introduce a breaking change?

  • Yes.
  • No.

@stevenjoezhang
Copy link
Contributor Author

stevenjoezhang commented Jul 13, 2019

See: https://www.measurethat.net/Benchmarks/Show/2978/0/lodash-merge-vs-objectassign-vs-spread

屏幕快照 2019-07-13 上午9 21 38

JavaScript microbenchmarks, JavaScript performance playground. Measure performance accross different browsers.

@jiangtj
Copy link
Member

jiangtj commented Jul 13, 2019

How about to support deep copy?

@stevenjoezhang
Copy link
Contributor Author

Like what...

@stevenjoezhang
Copy link
Contributor Author

stevenjoezhang commented Jul 13, 2019

https://github.com/theme-next/hexo-theme-next/blob/5067852e5f5ba4883064716b530c664ec0feeafc/.gitattributes

GitHub
Elegant and powerful theme for Hexo. Contribute to theme-next/hexo-theme-next development by creating an account on GitHub.

@stevenjoezhang stevenjoezhang merged commit 57289bc into master Jul 13, 2019
@delete-merged-branch delete-merged-branch bot deleted the merge branch July 13, 2019 05:19
@jiangtj
Copy link
Member

jiangtj commented Jul 13, 2019

image
image
image

😂

@jiangtj
Copy link
Member

jiangtj commented Jul 13, 2019

Hexo support lodash
image

@jiangtj
Copy link
Member

jiangtj commented Jul 13, 2019

Hexo support lodash

But I don't how to use 😂
image

@stevenjoezhang
Copy link
Contributor Author

I see. So it would better be
obj = Object.assign(obj, other)

@jiangtj
Copy link
Member

jiangtj commented Jul 13, 2019

I see. So it would better be
obj = Object.assign(obj, other)

I don't know, I also use Object.assign 😂 . But _.merge and Object.assign behave differently, need to pay attention or remind the user.

@1v9
Copy link
Member

1v9 commented Jul 13, 2019

@jiangtj const merge = require('lodash/merge');

@1v9
Copy link
Member

1v9 commented Jul 13, 2019

So, lodash merge vs Object.assign vs Spread syntax? Shallow copy? Deep copy? 😂

@stevenjoezhang
Copy link
Contributor Author

Problems occur if a user does not copy all sub-options under a root option...
In this particular case, Object.assign and lodash.merge have different properties
Since this is a function that executes only once, the performance issue is less critical to consider
So revert it: 74f2749

@1v9 1v9 removed this from the v7.3.0 milestone Jul 13, 2019
This was referenced Oct 9, 2019
tongluyang pushed a commit to tongluyang/hexo-theme-next that referenced this pull request Nov 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants