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

refactor(theme/view): simplify assignIn #3987

Merged
merged 1 commit into from Dec 19, 2019

Conversation

SukkaW
Copy link
Member

@SukkaW SukkaW commented Dec 18, 2019

What does it do?

The continuation of #3969 (#3753).

underscore.js has a createAssigner() which is a internal function for _.extend, _.defaults & _.assign:

_.extend = createAssigner(_.allKeys);
_.assign = createAssigner(_.keys);
_.defaults = createAssigner(_.allKeys, true);

When bring up #3969, I just simply merge and rewrite createAssigner(_.allKeys):

// Below is a part of _.allKeys which is unnecessary for assignIn itself
const keys = [];
for (const key in source) keys.push(key);

// Iterate Object from keys
const l = keys.length;	
for (let i = 0; i < l; i++) {
  const key = keys[i];
  obj[key] = source[key];
}

This PR simplify the assignIn() by directly iterating Object.

How to test

git clone -b simplify-assignIn https://github.com/sukkaw/hexo.git
cd hexo
npm install
npm test

Screenshots

Pull request tasks

  • Add test cases for the changes.
  • Passed the CI test.

@SukkaW SukkaW requested review from curbengh and a team December 18, 2019 15:45
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.004%) to 97.114% when pulling 809cb78 on SukkaW:simplify-assignIn into fa59eb2 on hexojs:master.

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.

None yet

3 participants