-
Notifications
You must be signed in to change notification settings - Fork 7
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
feat: add improved prune() function #29
base: master
Are you sure you want to change the base?
Conversation
'#': d.pkg( | ||
name='reflect', | ||
url='github.com/jsonnet-libs/xtd/reflect.libsonnet', | ||
help='`reflect` implements helper functions for processing json data.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
help='`reflect` implements helper functions for processing json data.', | |
help='`reflect` implements helper functions for processing JSON data.', |
else true; | ||
local doRecursion(x) = | ||
if recurse | ||
then self.prune(x, only_null=only_null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think it's more common to see that the recursive call uses the exact same arguments as the initial call because it explicitly demonstrates that the recursive call is gonna continue the same behavior.
then self.prune(x, only_null=only_null) | |
then self.prune(x, recurse, only_null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For completeness, I think that all primitives need to exist in the test objects or at least zero-length arrays to demonstrate that the same std.prune
behavior is preserved.
It often comes up that
std.prune()
is recursive, although the documentation states that it is, this still catches people off guard.The function introduced here provides options to disable recursion and only prune
null
values.