Refactor data.js to use a `Map`
See original GitHub issueIt seems dom/data.js is the perfect candidate for using a Map
instead of the custom implementation.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Simplifying code with Maps in JavaScript | Alex Khomenko
Now that we're familiar with maps, let's refactor our component to take advantage of this data structure. const typeMap = new Map([ ["sessions" ......
Read more >Refactoring every .forEach to a .map - DEV Community
1. Use cases. map returns a new array without mutating the original, so it makes sense to use it if we are planning...
Read more >Refactor React Code - Map Through API Data and ... - YouTube
Hi! I had a few people suggest that we break down the "Featured" component and pass through data to a component and then...
Read more >How can I refactor my code to Javascript ES6 using map or ...
I would just generate a predicate from the second parameter. Since it contains a keys and a values, then Object.entries will de-compose it ......
Read more >How to Use Map, Filter, and Reduce in JavaScript - Code
map is a method built to do exactly that. It's defined on Array.prototype , so you can call it on any array, and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
yep it’s intended currently we don’t allow to use more than one plugin on a element
@Johann-S sorry my stupid questions, but I try to fully understand the intention behind this code.
The current implementation, as far as I get it, doesn’t allow for multiple
data
on a singleelement
at the same time, becausesetData
will reuse thebsKey
if it exists and override whateverdata
that is instoreData
(without updating thekey
in that case). If you callsetData
on anelement
with differentkey
s it will always override the information of the first usedkey
, andgetData
will always return null for every otherkey
aside the first one used. That’s the intended design?Here is an example of an albeit fictional case that shows the implication of what I’m trying to say: https://codepen.io/-alpa-/pen/KKMExwM