This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Replace items in `as` with a matching `id` with the | |
// respective item in `bs`, otherwise append new items. | |
const abs = Object.fromEntries([ | |
...as.map(a => [a.id, a]), | |
...bs.map(b => [b.id, b]) | |
]); | |
// The 'trick' is that if you have two entries with the same id | |
// (in this case, implying that the value was updated within `bs`) | |
// then with this method the value of the right-most entry will be used. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If I get time I will implement an immutable version of
Counter
.