Leonidas-from-XIV / node-xml2js

XML to JavaScript object converter.
MIT License
4.88k stars 602 forks source link

Allow function as default value for parsing empty tags #512

Closed honzas closed 4 years ago

honzas commented 5 years ago

We can now specify empty object as default value when parsing xml. This empty object is then shared as a reference across all occurences - when we assign something to it, new value appears in all default empty objects (we don't want that).

By specifying function as default value for empty object, we can provide factory function which creates new empty object for each occurence individually.

coveralls commented 5 years ago

Coverage Status

Coverage increased (+0.01%) to 97.647% when pulling f074644bc32ae6f3012962686ad70188bf98f61a on economia:master into 0f0a2980b3db5366b3d50e4d0da422cb7af100c9 on Leonidas-from-XIV:master.

coveralls commented 5 years ago

Coverage Status

Coverage increased (+0.01%) to 97.647% when pulling fa32064c935a3b2b7bc05eab7599c769994c7a0c on economia:master into 0f0a2980b3db5366b3d50e4d0da422cb7af100c9 on Leonidas-from-XIV:master.

ozknemoy commented 5 years ago

@Leonidas-from-XIV can you please merge this PR

ozknemoy commented 5 years ago

@honzas can you please add description of this new feature to README.md

ozknemoy commented 5 years ago

@honzas sorry for latter plea. can you please add to emptyTag callback param of current value of tag. often ' ' (space) ignored by xml2js and 2 neighbor words collapsed

honzas commented 5 years ago

@ozknemoy not sure what you mean - could you give me an example?

ozknemoy commented 5 years ago

@honzas sorry ... dig deeper into code and understood that its not the case

Leonidas-from-XIV commented 4 years ago

Thanks, looks good to me and a sensible solution to the problem of shared mutable references. Sorry for the long silence.