Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow function as default value for parsing empty tags #512

Merged
merged 3 commits into from
Mar 27, 2020

Conversation

honzas
Copy link

@honzas honzas commented Jun 5, 2019

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.

Jan Stepanek added 2 commits May 21, 2019 19:06
In case there are multiple empty tags in xml,
they all share reference to the same default object. This causes unwanted
duplication, when we assign something to any of these empty objects.
When we provide factory function for emptyObject, these objects no longer
share reference and works as expected.
@coveralls
Copy link

Coverage Status

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

@coveralls
Copy link

coveralls commented Jun 5, 2019

Coverage Status

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

@ozknemoy
Copy link

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

@ozknemoy
Copy link

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

@ozknemoy
Copy link

@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
Copy link
Author

honzas commented Jun 23, 2019

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

@ozknemoy
Copy link

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

@Leonidas-from-XIV Leonidas-from-XIV merged commit 1832e0b into Leonidas-from-XIV:master Mar 27, 2020
@Leonidas-from-XIV
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants