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

Be consistent with use of values() for collections #248

Open
5 tasks
Tracked by #250
nexushoratio opened this issue Feb 11, 2024 · 0 comments
Open
5 tasks
Tracked by #250

Be consistent with use of values() for collections #248

nexushoratio opened this issue Feb 11, 2024 · 0 comments
Labels
cleanup This doesn't seem right, refactor, etc library For libraries linkedin-tool For the LinkedIn Tool userscript

Comments

@nexushoratio
Copy link
Owner

The primary collections, Array, Set, and Map, all support iterating on the instance:

for (const for of bar) {
  ...
}

Unfortunately, the default iterator for Map is [key, value], as provided by the entries() method, while for both Array and Set, it is values().

Due to this inconsistency, it may make sense to always explicitly use the values() method.

But, such a policy would mean that every loop over an array would be a bit noisier with that method call, and it is a pretty common thing.

And there are also the DOM array-like objects NodeList, et al.

  • Research external policies
  • Experiment
  • Decide on one
  • Enforce via eslint if possible
  • Migrate
@nexushoratio nexushoratio added cleanup This doesn't seem right, refactor, etc linkedin-tool For the LinkedIn Tool userscript library For libraries labels Feb 11, 2024
@nexushoratio nexushoratio self-assigned this Feb 11, 2024
@nexushoratio nexushoratio removed their assignment Feb 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup This doesn't seem right, refactor, etc library For libraries linkedin-tool For the LinkedIn Tool userscript
Projects
None yet
Development

No branches or pull requests

1 participant