@port-labs/jq-node-bindings 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/deps/jq/COPYING +1 -9
- package/deps/jq/Makefile.am +13 -18
- package/deps/jq/NEWS.md +2 -2
- package/deps/jq/README.md +3 -18
- package/deps/jq/configure.ac +1 -0
- package/deps/jq/docs/Pipfile.lock +59 -72
- package/deps/jq/docs/README.md +1 -1
- package/deps/jq/docs/build_manpage.py +1 -1
- package/deps/jq/docs/build_mantests.py +1 -1
- package/deps/jq/docs/content/download/default.yml +1 -23
- package/deps/jq/docs/content/index.yml +0 -5
- package/deps/jq/docs/content/manual/{dev/manual.yml → manual.yml} +36 -162
- package/deps/jq/docs/content/manual/v1.3/manual.yml +5 -0
- package/deps/jq/docs/content/manual/v1.4/manual.yml +5 -0
- package/deps/jq/docs/content/manual/v1.5/manual.yml +8 -3
- package/deps/jq/docs/content/manual/v1.6/manual.yml +8 -3
- package/deps/jq/docs/content/manual/v1.7/manual.yml +11 -6
- package/deps/jq/docs/content/tutorial/default.yml +3 -3
- package/deps/jq/docs/manual_schema.yml +3 -0
- package/deps/jq/docs/templates/index.html.j2 +6 -6
- package/deps/jq/docs/templates/manual.html.j2 +1 -11
- package/deps/jq/jq.1.prebuilt +26 -162
- package/deps/jq/jq.spec +1 -1
- package/deps/jq/src/builtin.c +211 -298
- package/deps/jq/src/builtin.jq +7 -13
- package/deps/jq/src/bytecode.h +3 -8
- package/deps/jq/src/compile.c +2 -2
- package/deps/jq/src/decNumber/decBasic.c +1 -1
- package/deps/jq/src/decNumber/decCommon.c +1 -1
- package/deps/jq/src/decNumber/decNumber.c +4 -4
- package/deps/jq/src/execute.c +42 -22
- package/deps/jq/src/jq.h +1 -1
- package/deps/jq/src/jq_test.c +7 -69
- package/deps/jq/src/jv.c +12 -17
- package/deps/jq/src/jv.h +0 -3
- package/deps/jq/src/jv_aux.c +4 -3
- package/deps/jq/src/jv_dtoa.c +1 -1
- package/deps/jq/src/jv_parse.c +0 -2
- package/deps/jq/src/jv_print.c +27 -21
- package/deps/jq/src/jv_unicode.c +0 -18
- package/deps/jq/src/jv_unicode.h +0 -2
- package/deps/jq/src/lexer.c +262 -283
- package/deps/jq/src/lexer.h +2 -3
- package/deps/jq/src/lexer.l +1 -7
- package/deps/jq/src/libm.h +5 -15
- package/deps/jq/src/linker.c +4 -6
- package/deps/jq/src/main.c +252 -179
- package/deps/jq/src/util.c +35 -41
- package/deps/jq/src/util.h +1 -1
- package/deps/jq/tests/jq.test +10 -148
- package/deps/jq/tests/jq_fuzz_load_file.c +0 -1
- package/deps/jq/tests/man.test +8 -26
- package/deps/jq/tests/setup +0 -4
- package/deps/jq/tests/shtest +39 -150
- package/index.d.ts +3 -2
- package/lib/jq.js +2 -2
- package/lib/templateAsync.js +8 -15
- package/package.json +2 -2
- package/src/binding.cc +46 -27
- package/test/santiy-async.test.js +4 -0
- package/deps/jq/sig/v1.7.1/jq-1.7.1.tar.gz.asc +0 -16
- package/deps/jq/sig/v1.7.1/jq-1.7.1.zip.asc +0 -16
- package/deps/jq/sig/v1.7.1/jq-linux-amd64.asc +0 -16
- package/deps/jq/sig/v1.7.1/jq-linux-arm64.asc +0 -16
- package/deps/jq/sig/v1.7.1/jq-linux-armel.asc +0 -16
- package/deps/jq/sig/v1.7.1/jq-linux-armhf.asc +0 -16
- package/deps/jq/sig/v1.7.1/jq-linux-i386.asc +0 -16
- package/deps/jq/sig/v1.7.1/jq-linux-mips.asc +0 -16
- package/deps/jq/sig/v1.7.1/jq-linux-mips64.asc +0 -16
- package/deps/jq/sig/v1.7.1/jq-linux-mips64el.asc +0 -16
- package/deps/jq/sig/v1.7.1/jq-linux-mips64r6.asc +0 -16
- package/deps/jq/sig/v1.7.1/jq-linux-mips64r6el.asc +0 -16
- package/deps/jq/sig/v1.7.1/jq-linux-mipsel.asc +0 -16
- package/deps/jq/sig/v1.7.1/jq-linux-mipsr6.asc +0 -16
- package/deps/jq/sig/v1.7.1/jq-linux-mipsr6el.asc +0 -16
- package/deps/jq/sig/v1.7.1/jq-linux-powerpc.asc +0 -16
- package/deps/jq/sig/v1.7.1/jq-linux-ppc64el.asc +0 -16
- package/deps/jq/sig/v1.7.1/jq-linux-riscv64.asc +0 -16
- package/deps/jq/sig/v1.7.1/jq-linux-s390x.asc +0 -16
- package/deps/jq/sig/v1.7.1/jq-linux64.asc +0 -16
- package/deps/jq/sig/v1.7.1/jq-macos-amd64.asc +0 -16
- package/deps/jq/sig/v1.7.1/jq-macos-arm64.asc +0 -16
- package/deps/jq/sig/v1.7.1/jq-osx-amd64.asc +0 -16
- package/deps/jq/sig/v1.7.1/jq-win64.exe.asc +0 -16
- package/deps/jq/sig/v1.7.1/jq-windows-amd64.exe.asc +0 -16
- package/deps/jq/sig/v1.7.1/jq-windows-i386.exe.asc +0 -16
- package/deps/jq/sig/v1.7.1/sha256sum.txt +0 -26
- package/deps/jq/tests/uri.test +0 -38
- package/deps/jq/tests/uritest +0 -5
package/deps/jq/jq.1.prebuilt
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
.
|
|
2
|
-
.TH "JQ" "1" "
|
|
2
|
+
.TH "JQ" "1" "December 2023" "" ""
|
|
3
3
|
.
|
|
4
4
|
.SH "NAME"
|
|
5
5
|
\fBjq\fR \- Command\-line JSON processor
|
|
@@ -163,13 +163,13 @@ Implies \fB\-\-stream\fR\. Invalid JSON inputs produce no error values when \fB\
|
|
|
163
163
|
Use the \fBapplication/json\-seq\fR MIME type scheme for separating JSON texts in jq\'s input and output\. This means that an ASCII RS (record separator) character is printed before each value on output and an ASCII LF (line feed) is printed after every output\. Input JSON texts that fail to parse are ignored (but warned about), discarding all subsequent input until the next RS\. This mode also parses the output of jq without the \fB\-\-seq\fR option\.
|
|
164
164
|
.
|
|
165
165
|
.TP
|
|
166
|
-
\fB\-f\fR / \fB\-\-from\-file\fR:
|
|
166
|
+
\fB\-f filename\fR / \fB\-\-from\-file filename\fR:
|
|
167
167
|
.
|
|
168
168
|
.IP
|
|
169
|
-
Read
|
|
169
|
+
Read filter from the file rather than from a command line, like awk\'s \-f option\. You can also use \'#\' to make comments\.
|
|
170
170
|
.
|
|
171
171
|
.TP
|
|
172
|
-
\fB\-L directory\fR
|
|
172
|
+
\fB\-L directory\fR:
|
|
173
173
|
.
|
|
174
174
|
.IP
|
|
175
175
|
Prepend \fBdirectory\fR to the search list for modules\. If this option is used then no builtin search list is used\. See the section on modules below\.
|
|
@@ -181,7 +181,7 @@ Prepend \fBdirectory\fR to the search list for modules\. If this option is used
|
|
|
181
181
|
This option passes a value to the jq program as a predefined variable\. If you run jq with \fB\-\-arg foo bar\fR, then \fB$foo\fR is available in the program and has the value \fB"bar"\fR\. Note that \fBvalue\fR will be treated as a string, so \fB\-\-arg foo 123\fR will bind \fB$foo\fR to \fB"123"\fR\.
|
|
182
182
|
.
|
|
183
183
|
.IP
|
|
184
|
-
Named arguments are also available to the jq program as \fB$ARGS\.named\fR\.
|
|
184
|
+
Named arguments are also available to the jq program as \fB$ARGS\.named\fR\.
|
|
185
185
|
.
|
|
186
186
|
.TP
|
|
187
187
|
\fB\-\-argjson name JSON\-text\fR:
|
|
@@ -286,16 +286,13 @@ Although the identity filter never modifies the value of its input, jq processin
|
|
|
286
286
|
produces \fB1\.7976931348623157e+308\fR on at least one platform\. This is because, in the process of parsing the number, this particular version of jq has converted it to an IEEE754 double\-precision representation, losing precision\.
|
|
287
287
|
.
|
|
288
288
|
.P
|
|
289
|
-
The way in which jq handles numbers has changed over time and further changes are likely within the parameters set by the relevant JSON standards\.
|
|
290
|
-
.
|
|
291
|
-
.P
|
|
292
|
-
The following remarks are therefore offered with the understanding that they are intended to be descriptive of the current version of jq and should not be interpreted as being prescriptive:
|
|
289
|
+
The way in which jq handles numbers has changed over time and further changes are likely within the parameters set by the relevant JSON standards\. The following remarks are therefore offered with the understanding that they are intended to be descriptive of the current version of jq and should not be interpreted as being prescriptive:
|
|
293
290
|
.
|
|
294
291
|
.P
|
|
295
292
|
(1) Any arithmetic operation on a number that has not already been converted to an IEEE754 double precision representation will trigger a conversion to the IEEE754 representation\.
|
|
296
293
|
.
|
|
297
294
|
.P
|
|
298
|
-
(2) jq will attempt to maintain the original decimal precision of number literals
|
|
295
|
+
(2) jq will attempt to maintain the original decimal precision of number literals, but in expressions such \fB1E1234567890\fR, precision will be lost if the exponent is too large\.
|
|
299
296
|
.
|
|
300
297
|
.P
|
|
301
298
|
(3) In jq programs, a leading minus sign will trigger the conversion of the number to an IEEE754 representation\.
|
|
@@ -303,9 +300,6 @@ The following remarks are therefore offered with the understanding that they are
|
|
|
303
300
|
.P
|
|
304
301
|
(4) Comparisons are carried out using the untruncated big decimal representation of numbers if available, as illustrated in one of the following examples\.
|
|
305
302
|
.
|
|
306
|
-
.P
|
|
307
|
-
The examples below use the builtin function \fBhave_decnum\fR in order to demonstrate the expected effects of using / not using the \fB\-\-disable\-decnum\fR build configuration option, and also to allow automated tests derived from these examples to pass regardless of whether that option is used\.
|
|
308
|
-
.
|
|
309
303
|
.IP "" 4
|
|
310
304
|
.
|
|
311
305
|
.nf
|
|
@@ -318,21 +312,21 @@ jq \'\.\'
|
|
|
318
312
|
0\.12345678901234567890123456789
|
|
319
313
|
=> 0\.12345678901234567890123456789
|
|
320
314
|
|
|
321
|
-
jq \'[\., tojson]
|
|
315
|
+
jq \'[\., tojson]\'
|
|
322
316
|
12345678909876543212345
|
|
323
|
-
=>
|
|
317
|
+
=> [12345678909876543212345,"12345678909876543212345"]
|
|
324
318
|
|
|
325
319
|
jq \'\. < 0\.12345678901234567890123456788\'
|
|
326
320
|
0\.12345678901234567890123456789
|
|
327
321
|
=> false
|
|
328
322
|
|
|
329
|
-
jq \'map([\., \. == 1]) | tojson
|
|
323
|
+
jq \'map([\., \. == 1]) | tojson\'
|
|
330
324
|
[1, 1\.000, 1\.0, 100e\-2]
|
|
331
|
-
=> true
|
|
325
|
+
=> "[[1,true],[1\.000,true],[1\.0,true],[1\.00,true]]"
|
|
332
326
|
|
|
333
|
-
jq \'\. as $big | [$big, $big + 1] | map(\. > 10000000000000000000000000000000)
|
|
327
|
+
jq \'\. as $big | [$big, $big + 1] | map(\. > 10000000000000000000000000000000)\'
|
|
334
328
|
10000000000000000000000000000001
|
|
335
|
-
=> true
|
|
329
|
+
=> [true, false]
|
|
336
330
|
.
|
|
337
331
|
.fi
|
|
338
332
|
.
|
|
@@ -496,7 +490,7 @@ Like \fB\.[]\fR, but no errors will be output if \. is not an array or object\.
|
|
|
496
490
|
If two filters are separated by a comma, then the same input will be fed into both and the two filters\' output value streams will be concatenated in order: first, all of the outputs produced by the left expression, and then all of the outputs produced by the right\. For instance, filter \fB\.foo, \.bar\fR, produces both the "foo" fields and "bar" fields as separate outputs\.
|
|
497
491
|
.
|
|
498
492
|
.P
|
|
499
|
-
The \fB,\fR operator is one way to
|
|
493
|
+
The \fB,\fR operator is one way to contruct generators\.
|
|
500
494
|
.
|
|
501
495
|
.IP "" 4
|
|
502
496
|
.
|
|
@@ -1010,7 +1004,7 @@ When the input to \fBmap_values(f)\fR is an object, the output object has the sa
|
|
|
1010
1004
|
The key difference between \fBmap(f)\fR and \fBmap_values(f)\fR is that the former simply forms an array from all the values of \fB($x|f)\fR for each value, $x, in the input array or object, but \fBmap_values(f)\fR only uses \fBfirst($x|f)\fR\.
|
|
1011
1005
|
.
|
|
1012
1006
|
.P
|
|
1013
|
-
Specifically, for object inputs, \
|
|
1007
|
+
Specifically, for object inputs, \fBmap_value(f)\fR constructs the output object by examining in turn the value of \fBfirst(\.[$k]|f)\fR for each key, $k, of the input\. If this expression produces no values, then the corresponding key will be dropped; otherwise, the output object will have that value at the key, $k\.
|
|
1014
1008
|
.
|
|
1015
1009
|
.P
|
|
1016
1010
|
Here are some examples to clarify the behavior of \fBmap\fR and \fBmap_values\fR when applied to arrays\. These examples assume the input is \fB[1]\fR in all cases:
|
|
@@ -1340,15 +1334,12 @@ jq \'[paths(type == "number")]\'
|
|
|
1340
1334
|
.
|
|
1341
1335
|
.IP "" 0
|
|
1342
1336
|
.
|
|
1343
|
-
.SS "add
|
|
1337
|
+
.SS "add"
|
|
1344
1338
|
The filter \fBadd\fR takes as input an array, and produces as output the elements of the array added together\. This might mean summed, concatenated or merged depending on the types of the elements of the input array \- the rules are the same as those for the \fB+\fR operator (described above)\.
|
|
1345
1339
|
.
|
|
1346
1340
|
.P
|
|
1347
1341
|
If the input is an empty array, \fBadd\fR returns \fBnull\fR\.
|
|
1348
1342
|
.
|
|
1349
|
-
.P
|
|
1350
|
-
\fBadd(generator)\fR operates on the given generator rather than the input\.
|
|
1351
|
-
.
|
|
1352
1343
|
.IP "" 4
|
|
1353
1344
|
.
|
|
1354
1345
|
.nf
|
|
@@ -1364,10 +1355,6 @@ jq \'add\'
|
|
|
1364
1355
|
jq \'add\'
|
|
1365
1356
|
[]
|
|
1366
1357
|
=> null
|
|
1367
|
-
|
|
1368
|
-
jq \'add(\.[]\.a)\'
|
|
1369
|
-
[{"a":3}, {"a":5}, {"b":6}]
|
|
1370
|
-
=> 8
|
|
1371
1358
|
.
|
|
1372
1359
|
.fi
|
|
1373
1360
|
.
|
|
@@ -1943,30 +1930,6 @@ jq \'[\.[]|rtrimstr("foo")]\'
|
|
|
1943
1930
|
.
|
|
1944
1931
|
.IP "" 0
|
|
1945
1932
|
.
|
|
1946
|
-
.SS "trim, ltrim, rtrim"
|
|
1947
|
-
\fBtrim\fR trims both leading and trailing whitespace\.
|
|
1948
|
-
.
|
|
1949
|
-
.P
|
|
1950
|
-
\fBltrim\fR trims only leading (left side) whitespace\.
|
|
1951
|
-
.
|
|
1952
|
-
.P
|
|
1953
|
-
\fBrtrim\fR trims only trailing (right side) whitespace\.
|
|
1954
|
-
.
|
|
1955
|
-
.P
|
|
1956
|
-
Whitespace characters are the usual \fB" "\fR, \fB"\en"\fR \fB"\et"\fR, \fB"\er"\fR and also all characters in the Unicode character database with the whitespace property\. Note that what considers whitespace might change in the future\.
|
|
1957
|
-
.
|
|
1958
|
-
.IP "" 4
|
|
1959
|
-
.
|
|
1960
|
-
.nf
|
|
1961
|
-
|
|
1962
|
-
jq \'trim, ltrim, rtrim\'
|
|
1963
|
-
" abc "
|
|
1964
|
-
=> "abc", "abc ", " abc"
|
|
1965
|
-
.
|
|
1966
|
-
.fi
|
|
1967
|
-
.
|
|
1968
|
-
.IP "" 0
|
|
1969
|
-
.
|
|
1970
1933
|
.SS "explode"
|
|
1971
1934
|
Converts an input string into an array of the string\'s codepoint numbers\.
|
|
1972
1935
|
.
|
|
@@ -2189,17 +2152,11 @@ jq \'walk( if type == "object" then with_entries( \.key |= sub( "^_+"; "") ) els
|
|
|
2189
2152
|
.
|
|
2190
2153
|
.IP "" 0
|
|
2191
2154
|
.
|
|
2192
|
-
.SS "have_literal_numbers"
|
|
2193
|
-
This builtin returns true if jq\'s build configuration includes support for preservation of input number literals\.
|
|
2194
|
-
.
|
|
2195
|
-
.SS "have_decnum"
|
|
2196
|
-
This builtin returns true if jq was built with "decnum", which is the current literal number preserving numeric backend implementation for jq\.
|
|
2197
|
-
.
|
|
2198
2155
|
.SS "$JQ_BUILD_CONFIGURATION"
|
|
2199
2156
|
This builtin binding shows the jq executable\'s build configuration\. Its value has no particular format, but it can be expected to be at least the \fB\./configure\fR command\-line arguments, and may be enriched in the future to include the version strings for the build tooling used\.
|
|
2200
2157
|
.
|
|
2201
2158
|
.P
|
|
2202
|
-
Note that this can be
|
|
2159
|
+
Note that this can be overriden in the command\-line with \fB\-\-arg\fR and related options\.
|
|
2203
2160
|
.
|
|
2204
2161
|
.SS "$ENV, env"
|
|
2205
2162
|
\fB$ENV\fR is an object representing the environment variables as set when the jq program started\.
|
|
@@ -2330,12 +2287,6 @@ Applies HTML/XML escaping, by mapping the characters \fB<>&\'"\fR to their entit
|
|
|
2330
2287
|
Applies percent\-encoding, by mapping all reserved URI characters to a \fB%XX\fR sequence\.
|
|
2331
2288
|
.
|
|
2332
2289
|
.TP
|
|
2333
|
-
\fB@urid\fR:
|
|
2334
|
-
.
|
|
2335
|
-
.IP
|
|
2336
|
-
The inverse of \fB@uri\fR, applies percent\-decoding, by mapping all \fB%XX\fR sequences to their corresponding URI characters\.
|
|
2337
|
-
.
|
|
2338
|
-
.TP
|
|
2339
2290
|
\fB@csv\fR:
|
|
2340
2291
|
.
|
|
2341
2292
|
.IP
|
|
@@ -2446,7 +2397,7 @@ The \fBlocaltime\fR builtin works like the \fBgmtime\fR builtin, but using the l
|
|
|
2446
2397
|
The \fBmktime\fR builtin consumes "broken down time" representations of time output by \fBgmtime\fR and \fBstrptime\fR\.
|
|
2447
2398
|
.
|
|
2448
2399
|
.P
|
|
2449
|
-
The \fBstrptime(fmt)\fR builtin parses input strings matching the \fBfmt\fR argument\. The output is in the "broken down time" representation consumed by \
|
|
2400
|
+
The \fBstrptime(fmt)\fR builtin parses input strings matching the \fBfmt\fR argument\. The output is in the "broken down time" representation consumed by \fBgmtime\fR and output by \fBmktime\fR\.
|
|
2450
2401
|
.
|
|
2451
2402
|
.P
|
|
2452
2403
|
The \fBstrftime(fmt)\fR builtin formats a time (GMT) with the given format\. The \fBstrflocaltime\fR does the same, but using the local timezone setting\.
|
|
@@ -2733,7 +2684,7 @@ label $out | \.\.\. break $out \.\.\.
|
|
|
2733
2684
|
.IP "" 0
|
|
2734
2685
|
.
|
|
2735
2686
|
.P
|
|
2736
|
-
The \fBbreak $label_name\fR expression will cause the program to act as though the nearest (to the left) \fBlabel $label_name\fR produced \fBempty\fR\.
|
|
2687
|
+
The \fBbreak $label_name\fR expression will cause the program to to act as though the nearest (to the left) \fBlabel $label_name\fR produced \fBempty\fR\.
|
|
2737
2688
|
.
|
|
2738
2689
|
.P
|
|
2739
2690
|
The relationship between the \fBbreak\fR and corresponding \fBlabel\fR is lexical: the label has to be "visible" from the break\.
|
|
@@ -3435,14 +3386,14 @@ jq \'isempty(\.[])\'
|
|
|
3435
3386
|
.
|
|
3436
3387
|
.IP "" 0
|
|
3437
3388
|
.
|
|
3438
|
-
.SS "limit(n;
|
|
3439
|
-
The \fBlimit\fR function extracts up to \fBn\fR outputs from \
|
|
3389
|
+
.SS "limit(n; exp)"
|
|
3390
|
+
The \fBlimit\fR function extracts up to \fBn\fR outputs from \fBexp\fR\.
|
|
3440
3391
|
.
|
|
3441
3392
|
.IP "" 4
|
|
3442
3393
|
.
|
|
3443
3394
|
.nf
|
|
3444
3395
|
|
|
3445
|
-
jq \'[limit(3
|
|
3396
|
+
jq \'[limit(3;\.[])]\'
|
|
3446
3397
|
[0,1,2,3,4,5,6,7,8,9]
|
|
3447
3398
|
=> [0,1,2]
|
|
3448
3399
|
.
|
|
@@ -3450,21 +3401,6 @@ jq \'[limit(3; \.[])]\'
|
|
|
3450
3401
|
.
|
|
3451
3402
|
.IP "" 0
|
|
3452
3403
|
.
|
|
3453
|
-
.SS "skip(n; expr)"
|
|
3454
|
-
The \fBskip\fR function skips the first \fBn\fR outputs from \fBexpr\fR\.
|
|
3455
|
-
.
|
|
3456
|
-
.IP "" 4
|
|
3457
|
-
.
|
|
3458
|
-
.nf
|
|
3459
|
-
|
|
3460
|
-
jq \'[skip(3; \.[])]\'
|
|
3461
|
-
[0,1,2,3,4,5,6,7,8,9]
|
|
3462
|
-
=> [3,4,5,6,7,8,9]
|
|
3463
|
-
.
|
|
3464
|
-
.fi
|
|
3465
|
-
.
|
|
3466
|
-
.IP "" 0
|
|
3467
|
-
.
|
|
3468
3404
|
.SS "first(expr), last(expr), nth(n; expr)"
|
|
3469
3405
|
The \fBfirst(expr)\fR and \fBlast(expr)\fR functions extract the first and last values from \fBexpr\fR, respectively\.
|
|
3470
3406
|
.
|
|
@@ -3475,13 +3411,9 @@ The \fBnth(n; expr)\fR function extracts the nth value output by \fBexpr\fR\. No
|
|
|
3475
3411
|
.
|
|
3476
3412
|
.nf
|
|
3477
3413
|
|
|
3478
|
-
jq \'[first(range(\.)), last(range(\.)), nth(
|
|
3414
|
+
jq \'[first(range(\.)), last(range(\.)), nth(\./2; range(\.))]\'
|
|
3479
3415
|
10
|
|
3480
3416
|
=> [0,9,5]
|
|
3481
|
-
|
|
3482
|
-
jq \'[first(empty), last(empty), nth(5; empty)]\'
|
|
3483
|
-
null
|
|
3484
|
-
=> []
|
|
3485
3417
|
.
|
|
3486
3418
|
.fi
|
|
3487
3419
|
.
|
|
@@ -3666,7 +3598,7 @@ Besides simple arithmetic operators such as \fB+\fR, jq also has most standard m
|
|
|
3666
3598
|
Availability of standard math functions depends on the availability of the corresponding math functions in your operating system and C math library\. Unavailable math functions will be defined but will raise an error\.
|
|
3667
3599
|
.
|
|
3668
3600
|
.P
|
|
3669
|
-
One\-input C math functions: \fBacos\fR \fBacosh\fR \fBasin\fR \fBasinh\fR \fBatan\fR \fBatanh\fR \fBcbrt\fR \fBceil\fR \fBcos\fR \fBcosh\fR \fBerf\fR \fBerfc\fR \fBexp\fR \fBexp10\fR \fBexp2\fR \fBexpm1\fR \fBfabs\fR \fBfloor\fR \fBgamma\fR \fBj0\fR \fBj1\fR \fBlgamma\fR \fBlog\fR \fBlog10\fR \fBlog1p\fR \fBlog2\fR \fBlogb\fR \fBnearbyint\fR \fBrint\fR \fBround\fR \fBsignificand\fR \fBsin\fR \fBsinh\fR \fBsqrt\fR \fBtan\fR \fBtanh\fR \fBtgamma\fR \fBtrunc\fR \fBy0\fR \fBy1\fR\.
|
|
3601
|
+
One\-input C math functions: \fBacos\fR \fBacosh\fR \fBasin\fR \fBasinh\fR \fBatan\fR \fBatanh\fR \fBcbrt\fR \fBceil\fR \fBcos\fR \fBcosh\fR \fBerf\fR \fBerfc\fR \fBexp\fR \fBexp10\fR \fBexp2\fR \fBexpm1\fR \fBfabs\fR \fBfloor\fR \fBgamma\fR \fBj0\fR \fBj1\fR \fBlgamma\fR \fBlog\fR \fBlog10\fR \fBlog1p\fR \fBlog2\fR \fBlogb\fR \fBnearbyint\fR \fBpow10\fR \fBrint\fR \fBround\fR \fBsignificand\fR \fBsin\fR \fBsinh\fR \fBsqrt\fR \fBtan\fR \fBtanh\fR \fBtgamma\fR \fBtrunc\fR \fBy0\fR \fBy1\fR\.
|
|
3670
3602
|
.
|
|
3671
3603
|
.P
|
|
3672
3604
|
Two\-input C math functions: \fBatan2\fR \fBcopysign\fR \fBdrem\fR \fBfdim\fR \fBfmax\fR \fBfmin\fR \fBfmod\fR \fBfrexp\fR \fBhypot\fR \fBjn\fR \fBldexp\fR \fBmodf\fR \fBnextafter\fR \fBnexttoward\fR \fBpow\fR \fBremainder\fR \fBscalb\fR \fBscalbln\fR \fByn\fR\.
|
|
@@ -4023,74 +3955,6 @@ The paths provided by this operation point to each of the posts that "stedolan"
|
|
|
4023
3955
|
.
|
|
4024
3956
|
.IP "" 0
|
|
4025
3957
|
.
|
|
4026
|
-
.SH "COMMENTS"
|
|
4027
|
-
You can write comments in your jq filters using \fB#\fR\.
|
|
4028
|
-
.
|
|
4029
|
-
.P
|
|
4030
|
-
A \fB#\fR character (not part of a string) starts a comment\. All characters from \fB#\fR to the end of the line are ignored\.
|
|
4031
|
-
.
|
|
4032
|
-
.P
|
|
4033
|
-
If the end of the line is preceded by an odd number of backslash characters, the following line is also considered part of the comment and is ignored\.
|
|
4034
|
-
.
|
|
4035
|
-
.P
|
|
4036
|
-
For example, the following code outputs \fB[1,3,4,7]\fR
|
|
4037
|
-
.
|
|
4038
|
-
.IP "" 4
|
|
4039
|
-
.
|
|
4040
|
-
.nf
|
|
4041
|
-
|
|
4042
|
-
[
|
|
4043
|
-
1,
|
|
4044
|
-
# foo \e
|
|
4045
|
-
2,
|
|
4046
|
-
# bar \e\e
|
|
4047
|
-
3,
|
|
4048
|
-
4, # baz \e\e\e
|
|
4049
|
-
5, \e
|
|
4050
|
-
6,
|
|
4051
|
-
7
|
|
4052
|
-
# comment \e
|
|
4053
|
-
comment \e
|
|
4054
|
-
comment
|
|
4055
|
-
]
|
|
4056
|
-
.
|
|
4057
|
-
.fi
|
|
4058
|
-
.
|
|
4059
|
-
.IP "" 0
|
|
4060
|
-
.
|
|
4061
|
-
.P
|
|
4062
|
-
Backslash continuing the comment on the next line can be useful when writing the "shebang" for a jq script:
|
|
4063
|
-
.
|
|
4064
|
-
.IP "" 4
|
|
4065
|
-
.
|
|
4066
|
-
.nf
|
|
4067
|
-
|
|
4068
|
-
#!/bin/sh \-\-
|
|
4069
|
-
# total \- Output the sum of the given arguments (or stdin)
|
|
4070
|
-
# usage: total [numbers\.\.\.]
|
|
4071
|
-
# \e
|
|
4072
|
-
exec jq \-\-args \-MRnf \-\- "$0" "$@"
|
|
4073
|
-
|
|
4074
|
-
$ARGS\.positional |
|
|
4075
|
-
reduce (
|
|
4076
|
-
if \. == []
|
|
4077
|
-
then inputs
|
|
4078
|
-
else \.[]
|
|
4079
|
-
end |
|
|
4080
|
-
\. as $dot |
|
|
4081
|
-
try tonumber catch false |
|
|
4082
|
-
if not or isnan then
|
|
4083
|
-
@json "total: Invalid number \e($dot)\.\en" | halt_error(1)
|
|
4084
|
-
end
|
|
4085
|
-
) as $n (0; \. + $n)
|
|
4086
|
-
.
|
|
4087
|
-
.fi
|
|
4088
|
-
.
|
|
4089
|
-
.IP "" 0
|
|
4090
|
-
.
|
|
4091
|
-
.P
|
|
4092
|
-
The \fBexec\fR line is considered a comment by jq, so it is ignored\. But it is not ignored by \fBsh\fR, since in \fBsh\fR a backslash at the end of the line does not continue the comment\. With this trick, when the script is invoked as \fBtotal 1 2\fR, \fB/bin/sh \-\- /path/to/total 1 2\fR will be run, and \fBsh\fR will then run \fBexec jq \-\-args \-MRnf \-\- /path/to/total 1 2\fR replacing itself with a \fBjq\fR interpreter invoked with the specified options (\fB\-M\fR, \fB\-R\fR, \fB\-n\fR, \fB\-\-args\fR), that evaluates the current file (\fB$0\fR), with the arguments (\fB$@\fR) that were passed to \fBsh\fR\.
|
|
4093
|
-
.
|
|
4094
3958
|
.SH "MODULES"
|
|
4095
3959
|
jq has a library/module system\. Modules are files whose names end in \fB\.jq\fR\.
|
|
4096
3960
|
.
|
|
@@ -4098,7 +3962,7 @@ jq has a library/module system\. Modules are files whose names end in \fB\.jq\fR
|
|
|
4098
3962
|
Modules imported by a program are searched for in a default search path (see below)\. The \fBimport\fR and \fBinclude\fR directives allow the importer to alter this path\.
|
|
4099
3963
|
.
|
|
4100
3964
|
.P
|
|
4101
|
-
Paths in the search path are subject to various substitutions\.
|
|
3965
|
+
Paths in the a search path are subject to various substitutions\.
|
|
4102
3966
|
.
|
|
4103
3967
|
.P
|
|
4104
3968
|
For paths starting with \fB~/\fR, the user\'s home directory is substituted for \fB~\fR\.
|
|
@@ -4128,7 +3992,7 @@ Consecutive components with the same name are not allowed to avoid ambiguities (
|
|
|
4128
3992
|
For example, with \fB\-L$HOME/\.jq\fR a module \fBfoo\fR can be found in \fB$HOME/\.jq/foo\.jq\fR and \fB$HOME/\.jq/foo/foo\.jq\fR\.
|
|
4129
3993
|
.
|
|
4130
3994
|
.P
|
|
4131
|
-
If \fB
|
|
3995
|
+
If \fB$HOME/\.jq\fR is a file, it is sourced into the main program\.
|
|
4132
3996
|
.
|
|
4133
3997
|
.SS "import RelativePathString as NAME [<metadata>];"
|
|
4134
3998
|
Imports a module found at the given path relative to a directory in a search path\. A \fB\.jq\fR suffix will be added to the relative path string\. The module\'s symbols are prefixed with \fBNAME::\fR\.
|
package/deps/jq/jq.spec
CHANGED