Remove deprecated filters: leaf_paths, recurse_down
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by itchyny · committed by Nico Williams · parent 6944d81 · Browse files · 3 files·+2 added−15 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+2 added−15 removed
- tests:+0 added−4 removed
- other:+2 added−11 removed
Provenance
- Commit
0eceded- Tree
4d5b741- Author
itchyny <itchyny@cybozu.co.jp>- Committer
Nico Williams <nico@cryptonector.com>- Parent
6944d81
3 files changed+2 added−15 removed
modified:docs/content/manual/manual.yml+2 added-9 removed
1139 unmodified lines1140 - program: 'try error("\($__loc__)") catch .'1141 input: 'null'1142 output: ['"{\"file\":\"<top-level>\",\"line\":1}"']1143 1144- - title: "`paths`, `paths(node_filter)`, `leaf_paths`"1144+ - title: "`paths`, `paths(node_filter)`"1145 body: |1146 1147 `paths` outputs the paths to all the elements in its input1148 (except it does not output the empty list, representing .2 unmodified lines1151 `paths(f)` outputs the paths to any values for which `f` is true.1152 That is, `paths(numbers)` outputs the paths to all numeric1153 values.1154 1155- `leaf_paths` is an alias of `paths(scalars)`; `leaf_paths` is1156- *deprecated* and will be removed in the next major release.1157-1155 examples:1156 - program: '[paths]'1157 input: '[1,[[],{"a":2}]]'1158 output: ['[[0],[1],[1,0],[1,1],[1,1,"a"]]']575 unmodified lines1734 input: '4'1735 output: ['24']1736 1737 1741- - title: "`recurse(f)`, `recurse`, `recurse(f; condition)`, `recurse_down`"1738+ - title: "`recurse(f)`, `recurse`, `recurse(f; condition)`"1739 body: |1740 1741 The `recurse(f)` function allows you to search through a1742 recursive structure, and extract interesting data from all25 unmodified lines1768 as the computed value satisfies the condition. For example,1769 to generate all the integers, at least in principle, one1770 could write `recurse(.+1; true)`.1771 1775- For legacy reasons, `recurse_down` exists as an alias to1776- calling `recurse` without arguments. This alias is considered1777- *deprecated* and will be removed in the next major release.1778-1772 The recursive calls in `recurse` will not consume additional1773 memory whenever `f` produces at most a single output for each1774 input.1775 1683 unmodified linesmodified:src/builtin.jq-2 removed
34 unmodified lines35 # recurse36 def recurse(f): def r: ., (f | r); r;37 def recurse(f; cond): def r: ., (f | select(cond) | r); r;38 def recurse: recurse(.[]?);39-def recurse_down: recurse;39 40 def to_entries: [keys_unsorted[] as $k | {key: $k, value: .[$k]}];41 def from_entries: map({(.key // .Key // .name // .Name): (if has("value") then .value else .Value end)}) | add | .//={};42 def with_entries(f): to_entries | map(f) | from_entries;17 unmodified lines60 def strings: select(type == "string");61 def nulls: select(. == null);62 def values: select(. != null);63 def scalars: select(type|. != "array" and . != "object");65-def leaf_paths: paths(scalars);64 def join($x): reduce .[] as $i (null;65 (if .==null then "" else .+$x end) +66 ($i | if type=="boolean" or type=="number" then tostring else .//"" end)67 ) // "";211 unmodified linesmodified:tests/jq.test-4 removed
950 unmodified lines951 [paths]952 [1,[[],{"a":2}]]953 [[0],[1],[1,0],[1,1],[1,1,"a"]]954 955-[leaf_paths]956-[1,[[],{"a":2}]]957-[[0],[1,1,"a"]]958-955 ["foo",1] as $p | getpath($p), setpath($p; 20), delpaths([$p])956 {"bar": 42, "foo": ["a", "b", "c", "d"]}957 "b"958 {"bar": 42, "foo": ["a", 20, "c", "d"]}784 unmodified lines