You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Why does handleExtendsNodes use the Array.reduce function instead of Array.map? As far as I can see it's always a direct transformation, the purpose of Array.map.
Also, shouldn't the line m = m.concat(...) just be m.push(...)?
Using map and push instead of concat would simplify the code from this (I removed irrelevant lines):
I haven't tested this code so I'm not 100% sure it works as intended, but I don't see any reason why there's the need for reduce. I might however be missing something (probably very obvious), hence the question.
The text was updated successfully, but these errors were encountered:
I think you're right here, probably I was tinkering with other logic initially when I made it a reduce, then never changed it back. Wanna PR and change it, see if the tests pass?
I did some investigating, and it seems like I'm actually wrong. It's not a direct transformation because a single <block> element gets 'unwrapped' to multiple children.
I was right however about the possibility to simplify the last 2 lines:
I think I like option 2 better, and it's probably faster too. I don't think it's worth it to create a PR for this though, I'll most likely include it in #24.
Why does
handleExtendsNodes
use theArray.reduce
function instead ofArray.map
? As far as I can see it's always a direct transformation, the purpose ofArray.map
.Also, shouldn't the line
m = m.concat(...)
just bem.push(...)
?Using
map
andpush
instead ofconcat
would simplify the code from this (I removed irrelevant lines):to this:
I haven't tested this code so I'm not 100% sure it works as intended, but I don't see any reason why there's the need for
reduce
. I might however be missing something (probably very obvious), hence the question.The text was updated successfully, but these errors were encountered: