add a Map method #20
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "map-method"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The current way to iterate through an OrderedMap and update multiple values at once while maintaining order is
But because
updatecreates a newOrderedMapfor each key and internally usesfindeach time, it's a bit cumbersome to use.mapfixes this by only creating the newOrderedMapat the end.Alternatively, if the constructor for
OrderedMapwas made public by modifying the lib types, this code could just easily exist outside this lib.My specific use case is conditionally adding attrs to an existing ProseMirror schema nodes, which involves mapping and maintaining order.
Thanks!
I don't think this is a common enough pattern to warrant its own method. Since you're probably only doing the mapping once, to build up a schema, creating a new copy of the object for every property shouldn't be a big issue.
Pull request closed