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

Remove d3 map #102

Merged
merged 5 commits into from
May 19, 2017
Merged

Remove d3 map #102

merged 5 commits into from
May 19, 2017

Conversation

sirahd
Copy link
Contributor

@sirahd sirahd commented May 17, 2017

  • remove d3 map
  • refactor a little more
  • create a copy of options before supplement it, thus preventing causing side-effect to the original object

@sirahd
Copy link
Contributor Author

sirahd commented May 18, 2017

@domoritz please review this!


itemData.each(function (value: string, field: string) {
// prepare title
for (let field of Object.keys(itemData)) {
Copy link
Member

Choose a reason for hiding this comment

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

You need a hasownproperty here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think Object.keys() already returns the properties that's not under prototype chain. So I'm not sure if we need an if to check that again

Copy link
Member

Choose a reason for hiding this comment

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

I missed that. You are right!

Copy link
Member

Choose a reason for hiding this comment

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

But definitely use cosnt here.

Copy link
Member

Choose a reason for hiding this comment

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

for let field of Object.keys() looks like an overkill. (It will run the loop twice.)

I think better use for..in and hasOwnProperty.

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 the performance is almost the same. At least looking at jsperf. And for in with hasownproperty is not shorter. I'm okay with leaving this as is.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah but this is pretty nonstandard code. While hasOwnProperty is

Copy link
Member

Choose a reason for hiding this comment

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

I've seen all of them but sure, let's go with for in as it is the most standard. Here is the jsperf btw: https://jsperf.com/object-keys-vs-for-in-with-closure/13

Copy link
Member

@domoritz domoritz left a comment

Choose a reason for hiding this comment

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

  • Use const where possible
  • replace for of Object.keys with for in

@sirahd
Copy link
Contributor Author

sirahd commented May 18, 2017

@domoritz Please ignore the first 4 commits. It was because I rebase onto master.

@domoritz
Copy link
Member

Is this done?

@sirahd
Copy link
Contributor Author

sirahd commented May 19, 2017

Yes. You can merge it.

@domoritz domoritz merged commit d46ede6 into master May 19, 2017
@domoritz domoritz deleted the sh/removemap branch May 19, 2017 21:41
@github-actions
Copy link

🚀 PR was released in v0.27.0 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants