Special value to ignore entry
See original GitHub issueThanks for a very useful module!
I’m writing a fairly complex XML-generation program and there are cases where some attributes/elements may or may not be included, depending on the business logic. Right now, in order to ignore such an entry, I need to add an explicit condition that only adds the entry in case the condition is satisfied.
A simpler way to code would be to add the entry regardless, and reserve a special value, e.g. undefined
, to instruct the XML generator to ignore the entry when the special value is found.
For example, instead of writing:
const snippet = [{
'element1': 'hello',
}];
if (condition) {
snippet.push({ 'element2': 'goodbye' });
}
one could write:
const snippet = [{
'element1': 'hello'
}, {
'element2': condition ? 'goodbye' : undefined
}];
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
What would be the best way to ignore characters in a input
If I give a input like he7ck and I want it to ignore anything that isn't letters so it just takes the input...
Read more >Ignore Null in a Column that otherwise needs a Unique Value
The column can have many Null entries, but only one instance of each non-Null value. The workaround is to set up a second...
Read more >Ignore certain values after a specific date
I am trying to pull volume of data entries over time for my team but some of these people have moved to other...
Read more >Handling Null and Other Special Values - Tableau Help
A null value is a field that is blank, and signifies missing or unknown values. When you drag a measure or continuous date...
Read more >sqlite - SQL Query: if a row contains a specific value, ignore all ...
I would like to get the distinct list of process_names that do not have a row that has an input value found in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That worked great! Thank you.
I think I see what you’re saying. You can do this in JS like this: