Closed jujiale closed 1 week ago
That's a possibility. It would not be as performant and it would think returning both path and value would be best.
Alternatively a delete with a callback is another option.
I think the callback approach will be best. Not sure when I will have it done though.
thanks,I will also research how to achieve this. if done. I will submit a pr.
The jp.Modify might be a good example of how to implement. Not exactly the same but similar. It also depends on whether the delete should replace items in a list with nil or remove from list.
I've started a branch names expr-walk. The plan is to implement func (x Expr) Walk(data any, cb func(path Expr, data, parent any))
. That will walk the matching nodes and allow the cb
function to modify and/or collect matching nodes. It should be easy to implement a delete that returns the deleted values along with the path the deleted value was found at with this new function.
I've started a branch names expr-walk. The plan is to implement
func (x Expr) Walk(data any, cb func(path Expr, data, parent any))
. That will walk the matching nodes and allow thecb
function to modify and/or collect matching nodes. It should be easy to implement a delete that returns the deleted values along with the path the deleted value was found at with this new function.
thanks, that's awesome, I will have a look.
Only started the branch. Not even close to being ready for use. Just letting you know in case you wanted to keep an eye on it.
Only started the branch. Not even close to being ready for use. Just letting you know in case you wanted to keep an eye on it.
OK,get it!
The expr-walk branch is ready to be merged. I plan on merging and releasing tomorrow unless someone such as yourself has comments about it.
hello, I find in Del method. `
`
could ojg provide a del method. which could return those elements who have been deleted, thanks.