node-object-mapper
node-object-mapper copied to clipboard
The reverse
How can do a bidirectional mapper?
+1
Can you elaborate? E.g. sample use case?
This would be useful to have a mapper between a local format and a vendor format. E.g. you get an awkward XML file defined by a service provider and you map it to a simple to understand DTO. This is what actually works with node-object-mapper. The other other direction would be to get this DTO - maybe manipulated - back to the service provider XML form.
You can use something like lodash's invert
method to reverse the key-value pair of the mapping object: https://lodash.com/docs/4.17.10#invert