Skip to content
Myr

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

3 files+2 added−15 removed

modified:docs/content/manual/manual.yml+2 added-9 removed
1139 unmodified lines
1140 - program: 'try error("\($__loc__)") catch .'1141 input: 'null'1142 output: ['"{\"file\":\"<top-level>\",\"line\":1}"']11431144 - title: "`paths`, `paths(node_filter)`, `leaf_paths`"1144 - title: "`paths`, `paths(node_filter)`"1145 body: |11461147 `paths` outputs the paths to all the elements in its input1148 (except it does not output the empty list, representing .
2 unmodified lines
1151 `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.11541155 `leaf_paths` is an alias of `paths(scalars)`; `leaf_paths` is1156 *deprecated* and will be removed in the next major release.11571155 examples:1156 - program: '[paths]'1157 input: '[1,[[],{"a":2}]]'1158 output: ['[[0],[1],[1,0],[1,1],[1,1,"a"]]']
575 unmodified lines
1734 input: '4'1735 output: ['24']173617371741 - title: "`recurse(f)`, `recurse`, `recurse(f; condition)`, `recurse_down`"1738 - title: "`recurse(f)`, `recurse`, `recurse(f; condition)`"1739 body: |17401741 The `recurse(f)` function allows you to search through a1742 recursive structure, and extract interesting data from all
25 unmodified lines
1768 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)`.17711775 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.17781772 The recursive calls in `recurse` will not consume additional1773 memory whenever `f` produces at most a single output for each1774 input.1775
1683 unmodified lines
modified:src/builtin.jq-2 removed
34 unmodified lines
35# recurse36def recurse(f): def r: ., (f | r); r;37def recurse(f; cond): def r: ., (f | select(cond) | r); r;38def recurse: recurse(.[]?);39def recurse_down: recurse;3940def to_entries: [keys_unsorted[] as $k | {key: $k, value: .[$k]}];41def from_entries: map({(.key // .Key // .name // .Name): (if has("value") then .value else .Value end)}) | add | .//={};42def with_entries(f): to_entries | map(f) | from_entries;
17 unmodified lines
60def strings: select(type == "string");61def nulls: select(. == null);62def values: select(. != null);63def scalars: select(type|. != "array" and . != "object");65def leaf_paths: paths(scalars);64def 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 lines
modified:tests/jq.test-4 removed
950 unmodified lines
951[paths]952[1,[[],{"a":2}]]953[[0],[1],[1,0],[1,1],[1,1,"a"]]954955[leaf_paths]956[1,[[],{"a":2}]]957[[0],[1,1,"a"]]958955["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