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 cleanupIDs #1556

Merged
merged 1 commit into from
Sep 5, 2021
Merged

Refactor cleanupIDs #1556

merged 1 commit into from
Sep 5, 2021

Conversation

TrySound
Copy link
Member

@TrySound TrySound commented Sep 1, 2021

I still did get how id generation works but data flow is clear now at
least.

  • covered with types
  • migrated to visitor plugin api
  • got rid of traverse api

I still did get how id generation works but data flow is clear now at
least.

- covered with types
- migrated to visitor plugin api
- got rid of traverse api
Comment on lines +226 to +231
let refs = referencesById.get(id);
if (refs == null) {
refs = [];
referencesById.set(id, refs);
}
refs.push({ element: node, name, value });

Choose a reason for hiding this comment

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

Might be I missed something. Isn’t this the same, but slightly shorter:

const refs = referencesById.get(id) || [];
if (!refs.length) {
  referencesById.set(id, refs);
}
refs.push({ element: node, name, value });

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, though I prefer more explicit null check, length check is less obvious

Choose a reason for hiding this comment

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

Sure. I was just looking around for examples. Working on a custom plugin. Just to say, Visitor API is a pleasure to use.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks. All plugins will use visitor api. full, perItem and perItemReverse will be removed in v3.

@TrySound TrySound merged commit 298820b into master Sep 5, 2021
@TrySound TrySound deleted the refactor-cleanup-ids branch September 5, 2021 14:35
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.

3 participants