FilterPath returns a new [Option] where opt is only evaluated if filter f returns true for the current [Path] in the value tree. This filter is called even if a slice element or map entry is missing and provides an opportunity to ignore such cases. The filter function must be symmetric such that th
(f func(Path) bool, opt Option)
| 116 | // The option passed in may be an [Ignore], [Transformer], [Comparer], [Options], or |
| 117 | // a previously filtered [Option]. |
| 118 | func FilterPath(f func(Path) bool, opt Option) Option { |
| 119 | if f == nil { |
| 120 | panic("invalid path filter function") |
| 121 | } |
| 122 | if opt := normalizeOption(opt); opt != nil { |
| 123 | return &pathFilter{fnc: f, opt: opt} |
| 124 | } |
| 125 | return nil |
| 126 | } |
| 127 | |
| 128 | type pathFilter struct { |
| 129 | core |
searching dependent graphs…