Open ravinggenius opened 8 years ago
Any interest in this?
It sounds useful. Do you have a working solution for this that doesn't slow down all transformations? Seems to me that you have to do more checking at each stage.
I don't have a working solution yet so I don't know what the performance impact would be. I wanted to see what you (@kschiess) thought before starting.
It sounds useful.
Having a way to mark certain keys as optional could go a long way towards reducing mostly redundant transform rules. Here's a simple example to show what I'm asking for.
Instead of two rules:
... I'd like to write a single rule to encapsulate the core logic:
Notice the
optional
keyword passed intosimple
. The value ofoptional
could be the default value to yield to the block if the key isn't present. Alternatively it could be a simple boolean to indicate an optional key, and it would be up to the block to handle the missing value. Theoptional
argument should be available tosequence
andsubtree
as well.