1
1
local html = import 'html.libsonnet';
2
2
3
+
local exampleDocMultiline(mid, ex) =
4
+
html.spaceless([
5
+
html.p({}, 'Example:'),
6
+
html.pre({}, ex.input),
7
+
html.p({}, mid),
8
+
html.pre({}, ex.output),
9
+
])
10
+
;
11
+
3
12
{
4
13
intro: html.paragraphs([
5
14
|||
@@ -98,6 +107,8 @@ local html = import 'html.libsonnet';
98
107
<ul><code>std.pow(x, n)</code></ul>
99
108
<ul><code>std.exp(x)</code></ul>
100
109
<ul><code>std.log(x)</code></ul>
110
+
<ul><code>std.log2(x)</code></ul>
111
+
<ul><code>std.log10(x)</code></ul>
101
112
<ul><code>std.exponent(x)</code></ul>
102
113
<ul><code>std.mantissa(x)</code></ul>
103
114
<ul><code>std.floor(x)</code></ul>
@@ -109,12 +120,19 @@ local html = import 'html.libsonnet';
109
120
<ul><code>std.asin(x)</code></ul>
110
121
<ul><code>std.acos(x)</code></ul>
111
122
<ul><code>std.atan(x)</code></ul>
123
+
<ul><code>std.atan2(y, x)</code></ul>
124
+
<ul><code>std.deg2rad(x)</code></ul>
125
+
<ul><code>std.rad2deg(x)</code></ul>
126
+
<ul><code>std.hypot(a, b)</code></ul>
112
127
<ul><code>std.round(x)</code></ul>
113
128
<ul><code>std.isEven(x)</code></ul>
114
129
<ul><code>std.isOdd(x)</code></ul>
115
130
<ul><code>std.isInteger(x)</code></ul>
116
131
<ul><code>std.isDecimal(x)</code></ul>
117
132
</ul>
133
+
<p>
134
+
The constant <code>std.pi</code> is also available.
135
+
</p>
118
136
<p>
119
137
The function <code>std.mod(a, b)</code> is what the % operator is desugared to. It performs
120
138
modulo arithmetic if the left hand side is a number, or if the left hand side is a string,
@@ -199,11 +217,18 @@ local html = import 'html.libsonnet';
199
217
name: 'substr',
200
218
params: ['str', 'from', 'len'],
201
219
availableSince: '0.10.0',
202
-
description: |||
203
-
Returns a string that is the part of <code>s</code> that starts at offset <code>from</code>
204
-
and is <code>len</code> codepoints long. If the string <code>s</code> is shorter than
205
-
<code>from+len</code>, the suffix starting at position <code>from</code> will be returned.
206
-
|||,
220
+
description: html.paragraphs([
221
+
|||
222
+
Returns a string that is the part of <code>str</code> that starts at offset <code>from</code>
223
+
and is <code>len</code> codepoints long. If the string <code>str</code> is shorter than
224
+
<code>from+len</code>, the suffix starting at position <code>from</code> will be returned.
225
+
|||,
226
+
|||
227
+
The slice operator (e.g., <code>str[from:to]</code>) can also be used on strings, as an
228
+
alternative to this function. However, note that the slice operator takes a start and an
229
+
end index, but <code>std.substr</code> takes a start index and a length.
230
+
|||,
231
+
]),
207
232
},
208
233
{
209
234
name: 'findSubstr',
@@ -382,15 +407,15 @@ local html = import 'html.libsonnet';
382
407
{
383
408
name: 'trim',
384
409
params: ['str'],
385
-
availableSince: 'upcoming',
410
+
availableSince: '0.21.0',
386
411
description: |||
387
412
Returns a copy of string after eliminating leading and trailing whitespaces.
388
413
|||,
389
414
},
390
415
{
391
416
name: 'equalsIgnoreCase',
392
417
params: ['str1', 'str2'],
393
-
availableSince: 'upcoming',
418
+
availableSince: '0.21.0',
394
419
description: |||
395
420
Returns true if the the given <code>str1</code> is equal to <code>str2</code> by doing case insensitive comparison, false otherwise.
396
421
|||,
@@ -763,7 +788,7 @@ local html = import 'html.libsonnet';
763
788
|||),
764
789
],
765
790
examples: [
766
-
{
791
+
exampleDocMultiline('Yields a string containing this JSON:', {
767
792
input: |||
768
793
std.manifestJsonEx(
769
794
{
@@ -787,8 +812,8 @@ local html = import 'html.libsonnet';
787
812
y: { a: 1, b: 2, c: [1, 2] },
788
813
}, ' '
789
814
),
790
-
},
791
-
{
815
+
}),
816
+
exampleDocMultiline('Yields a string containing this JSON:', {
792
817
input: |||
793
818
std.manifestJsonEx(
794
819
{
@@ -803,7 +828,7 @@ local html = import 'html.libsonnet';
803
828
y: { a: 1, b: [1, 2] },
804
829
}, '', ' ', ' : '
805
830
),
806
-
},
831
+
}),
807
832
],
808
833
},
809
834
{
@@ -815,7 +840,7 @@ local html = import 'html.libsonnet';
815
840
it calls <code>std.manifestJsonEx</code> with a 4-space indent:
816
841
|||,
817
842
examples: [
818
-
{
843
+
exampleDocMultiline('Yields a string containing this JSON:', {
819
844
input: |||
820
845
std.manifestJson(
821
846
{
@@ -839,7 +864,7 @@ local html = import 'html.libsonnet';
839
864
y: { a: 1, b: 2, c: [1, 2] },
840
865
}
841
866
),
842
-
},
867
+
}),
843
868
],
844
869
},
845
870
{
@@ -851,7 +876,7 @@ local html = import 'html.libsonnet';
851
876
it calls <code>std.manifestJsonEx</code>:
852
877
|||,
853
878
examples: [
854
-
{
879
+
exampleDocMultiline('Yields a string containing this JSON:', {
855
880
input: |||
856
881
std.manifestJsonMinified(
857
882
{
@@ -875,7 +900,7 @@ local html = import 'html.libsonnet';
875
900
y: { a: 1, b: 2, c: [1, 2] },
876
901
}
877
902
),
878
-
},
903
+
}),
879
904
],
880
905
},
881
906
{
@@ -1046,7 +1071,7 @@ local html = import 'html.libsonnet';
1046
1071
one or more whitespaces that are used for indentation:
1047
1072
|||,
1048
1073
examples: [
1049
-
{
1074
+
exampleDocMultiline('Yields a string containing this TOML file:', {
1050
1075
input: |||
1051
1076
std.manifestTomlEx({
1052
1077
key1: "value",
@@ -1085,7 +1110,7 @@ local html = import 'html.libsonnet';
1085
1110
],
1086
1111
}, ' ')
1087
1112
),
1088
-
},
1113
+
}),
1089
1114
],
1090
1115
},
1091
1116
],
@@ -1209,21 +1234,31 @@ local html = import 'html.libsonnet';
1209
1234
name: 'foldl',
1210
1235
params: ['func', 'arr', 'init'],
1211
1236
availableSince: '0.10.0',
1212
-
description: |||
1213
-
Classic foldl function. Calls the function on the result of the previous function call and
1214
-
each array element, or <code>init</code> in the case of the initial element. Traverses the
1215
-
array from left to right.
1216
-
|||,
1237
+
description: html.paragraphs([
1238
+
|||
1239
+
Classic foldl function. Calls the function for each array element, passing the result from
1240
+
the previous call (or <code>init</code> for the first call), and the array element. Traverses
1241
+
the array from left to right.
1242
+
|||,
1243
+
|||
1244
+
For example: <code>foldl(f, [1,2,3], 0)</code> is equivalent to <code>f(f(f(0, 1), 2), 3)</code>.
1245
+
|||,
1246
+
]),
1217
1247
},
1218
1248
{
1219
1249
name: 'foldr',
1220
1250
params: ['func', 'arr', 'init'],
1221
1251
availableSince: '0.10.0',
1222
-
description: |||
1223
-
Classic foldr function. Calls the function on the result of the previous function call and
1224
-
each array element, or <code>init</code> in the case of the initial element. Traverses the
1225
-
array from right to left.
1226
-
|||,
1252
+
description: html.paragraphs([
1253
+
|||
1254
+
Classic foldr function. Calls the function for each array element, passing the array element
1255
+
and the result from the previous call (or <code>init</code> for the first call). Traverses
1256
+
the array from right to left.
1257
+
|||,
1258
+
|||
1259
+
For example: <code>foldr(f, [1,2,3], 0)</code> is equivalent to <code>f(1, f(2, f(3, 0)))</code>.
1260
+
|||,
1261
+
]),
1227
1262
},
1228
1263
{
1229
1264
name: 'range',
@@ -1303,6 +1338,26 @@ local html = import 'html.libsonnet';
1303
1338
},
1304
1339
],
1305
1340
},
1341
+
{
1342
+
name: 'deepJoin',
1343
+
params: ['arr'],
1344
+
availableSince: '0.10.0',
1345
+
description: |||
1346
+
Concatenate an array containing strings and arrays to form a single string. If <code>arr</code> is
1347
+
a string, it is returned unchanged. If it is an array, it is flattened and the string elements are
1348
+
concatenated together with no separator.
1349
+
|||,
1350
+
examples: [
1351
+
{
1352
+
input: 'std.deepJoin(["one ", ["two ", "three ", ["four "], []], "five ", ["six"]])',
1353
+
output: std.deepJoin(['one ', ['two ', 'three ', ['four '], []], 'five ', ['six']]),
1354
+
},
1355
+
{
1356
+
input: 'std.deepJoin("hello")',
1357
+
output: std.deepJoin('hello'),
1358
+
},
1359
+
],
1360
+
},
1306
1361
{
1307
1362
name: 'lines',
1308
1363
params: ['arr'],
@@ -1329,7 +1384,7 @@ local html = import 'html.libsonnet';
1329
1384
{
1330
1385
name: 'flattenDeepArray',
1331
1386
params: ['value'],
1332
-
availableSince: 'upcoming',
1387
+
availableSince: '0.21.0',
1333
1388
description: |||
1334
1389
Concatenate an array containing values and arrays into a single flattened array.
1335
1390
|||,
@@ -1415,27 +1470,35 @@ local html = import 'html.libsonnet';
1415
1470
{
1416
1471
name: 'minArray',
1417
1472
params: ['arr', 'keyF', 'onEmpty'],
1418
-
availableSince: 'upcoming',
1473
+
availableSince: '0.21.0',
1419
1474
description: html.paragraphs([
1420
1475
|||
1421
-
Return the min of all element in <code>arr</code>.
1476
+
Return the minimum of all elements in <code>arr</code>. If <code>keyF</code> is provided, it is called on each element
1477
+
of the array and should return a comparator value, and in this case <code>minArray</code> will return an element
1478
+
with the minimum comparator value. If <code>onEmpty</code> is provided, and <code>arr</code> is empty, then
1479
+
<code>minArray</code> will return the provided <code>onEmpty</code> value. If <code>onEmpty</code> is not provided,
1480
+
then an empty <code>arr</code> will raise an error.
1422
1481
|||,
1423
1482
]),
1424
1483
},
1425
1484
{
1426
1485
name: 'maxArray',
1427
1486
params: ['arr', 'keyF', 'onEmpty'],
1428
-
availableSince: 'upcoming',
1487
+
availableSince: '0.21.0',
1429
1488
description: html.paragraphs([
1430
1489
|||
1431
-
Return the max of all element in <code>arr</code>.
1490
+
Return the maximum of all elements in <code>arr</code>. If <code>keyF</code> is provided, it is called on each element
1491
+
of the array and should return a comparator value, and in this case <code>maxArray</code> will return an element
1492
+
with the maximum comparator value. If <code>onEmpty</code> is provided, and <code>arr</code> is empty, then
1493
+
<code>maxArray</code> will return the provided <code>onEmpty</code> value. If <code>onEmpty</code> is not provided,
1494
+
then an empty <code>arr</code> will raise an error.
1432
1495
|||,
1433
1496
]),
1434
1497
},
1435
1498
{
1436
1499
name: 'contains',
1437
1500
params: ['arr', 'elem'],
1438
-
availableSince: 'upcoming',
1501
+
availableSince: '0.21.0',
1439
1502
description: html.paragraphs([
1440
1503
|||
1441
1504
Return true if given <code>elem</code> is present in <code>arr</code>, false otherwise.
@@ -1455,7 +1518,7 @@ local html = import 'html.libsonnet';
1455
1518
{
1456
1519
name: 'remove',
1457
1520
params: ['arr', 'elem'],
1458
-
availableSince: 'upcoming',
1521
+
availableSince: '0.21.0',
1459
1522
description: html.paragraphs([
1460
1523
|||
1461
1524
Remove first occurrence of <code>elem</code> from <code>arr</code>.
@@ -1465,7 +1528,7 @@ local html = import 'html.libsonnet';
1465
1528
{
1466
1529
name: 'removeAt',
1467
1530
params: ['arr', 'idx'],
1468
-
availableSince: 'upcoming',
1531
+
availableSince: '0.21.0',
1469
1532
description: html.paragraphs([
1470
1533
|||
1471
1534
Remove element at <code>idx</code> index from <code>arr</code>.
@@ -1593,7 +1656,7 @@ local html = import 'html.libsonnet';
1593
1656
params: ['o'],
1594
1657
availableSince: '0.20.0',
1595
1658
description: |||
1596
-
Returns an array of objects from the given object, each object having two fields:
1659
+
Returns an array of objects from the given object, each object having two fields:
1597
1660
<code>key</code> (string) and <code>value</code> (object). Does not include hidden fields.
1598
1661
|||,
1599
1662
},
@@ -1632,7 +1695,7 @@ local html = import 'html.libsonnet';
1632
1695
{
1633
1696
name: 'objectRemoveKey',
1634
1697
params: ['obj', 'key'],
1635
-
availableSince: 'upcoming',
1698
+
availableSince: '0.21.0',
1636
1699
description: |||
1637
1700
Returns a new object after removing the given key from object.
1638
1701
|||,
@@ -1699,7 +1762,7 @@ local html = import 'html.libsonnet';
1699
1762
{
1700
1763
name: 'sha1',
1701
1764
params: ['s'],
1702
-
availableSince: 'upcoming',
1765
+
availableSince: '0.21.0',
1703
1766
description: [
1704
1767
html.p({}, |||
1705
1768
Encodes the given value into an SHA1 string.
@@ -1712,7 +1775,7 @@ local html = import 'html.libsonnet';
1712
1775
{
1713
1776
name: 'sha256',
1714
1777
params: ['s'],
1715
-
availableSince: 'upcoming',
1778
+
availableSince: '0.21.0',
1716
1779
description: [
1717
1780
html.p({}, |||
1718
1781
Encodes the given value into an SHA256 string.
@@ -1725,7 +1788,7 @@ local html = import 'html.libsonnet';
1725
1788
{
1726
1789
name: 'sha512',
1727
1790
params: ['s'],
1728
-
availableSince: 'upcoming',
1791
+
availableSince: '0.21.0',
1729
1792
description: [
1730
1793
html.p({}, |||
1731
1794
Encodes the given value into an SHA512 string.
@@ -1738,7 +1801,7 @@ local html = import 'html.libsonnet';
1738
1801
{
1739
1802
name: 'sha3',
1740
1803
params: ['s'],
1741
-
availableSince: 'upcoming',
1804
+
availableSince: '0.21.0',
1742
1805
description: [
1743
1806
html.p({}, |||
1744
1807
Encodes the given value into an SHA3 string.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4