Debian Codegraph @

doc/ref/stdlib.html

raw
1 ---
2 # AUTOGENERATED FILE. DO NOT EDIT BY HAND!
3 layout: stdlib
4 title: Standard Library
5 ---
6
7 <div class="hgroup">
8 <div class="hgroup-inline">
9 <div class="panel">
10 <h1 id="standard_library">
11 Standard Library
12 </h1>
13 </div>
14 <div style="clear: both"></div>
15 </div>
16 </div>
17
18 <div class="hgroup">
19 <div class="hgroup-inline">
20 <div class="panel">
21 <p>
22 This page describes the functions available in Jsonnet's standard library, i.e. the object
23 implicitly bound to the <code>std</code> variable. Some of the standard library functions
24 can be implemented in Jsonnet. Their code can be found in the <tt>std.jsonnet</tt> file.
25 The behavior of some of the other functions, i.e. the ones that expose extra functionality
26 not otherwise available to programmers, is described formally in the <a href="/language/spec.html">specification</a>.
27 </p>
28 <p>
29 The standard library is implicitly added to all Jsonnet programs by enclosing them in a
30 local construct. For example, if the program given by the user is <code>{x: "foo"}</code>,
31 then the actual code executed would be <code>local std = { ... }; {x: "foo"}</code>. The
32 functions in the standard library are all hidden fields of the <code>std</code> object.
33 </p>
34 <p>
35 Note: Some of these functions marked available since v0.10.0 were actually available earlier.
36 </p>
37 </div>
38 <div style="clear: both"></div>
39 </div>
40 </div>
41
42 <div class="hgroup">
43 <div class="hgroup-inline">
44 <div class="panel">
45 <h3 id="ext_vars">
46 External Variables
47 </h3>
48 </div>
49 <div style="clear: both"></div>
50 </div>
51 </div>
52
53 <div class="hgroup">
54 <div class="hgroup-inline">
55 <div class="panel">
56 <h4 id="std-extVar">
57 std.extVar(x)
58 </h4>
59 </div>
60 <div style="clear: both"></div>
61 </div>
62 </div>
63 <div class="hgroup">
64 <div class="hgroup-inline">
65 <div class="panel">
66 <p>
67 <em>
68 Available since version 0.10.0.
69 </em>
70 </p>
71 <p>
72 If an external variable with the given name was defined, return its value. Otherwise, raise an error.
73 </p>
74
75 </div>
76 <div style="clear: both"></div>
77 </div>
78 </div>
79
80
81 <div class="hgroup">
82 <div class="hgroup-inline">
83 <div class="panel">
84 <h3 id="types_reflection">
85 Types and Reflection
86 </h3>
87 </div>
88 <div style="clear: both"></div>
89 </div>
90 </div>
91
92 <div class="hgroup">
93 <div class="hgroup-inline">
94 <div class="panel">
95 <h4 id="std-thisFile">
96 std.thisFile
97 </h4>
98 </div>
99 <div style="clear: both"></div>
100 </div>
101 </div>
102 <div class="hgroup">
103 <div class="hgroup-inline">
104 <div class="panel">
105 <p>
106 <em>
107 Available since version 0.10.0.
108 </em>
109 </p>
110 <p>
111 Note that this is a field. It contains the current Jsonnet filename as a string.
112 </p>
113
114 </div>
115 <div style="clear: both"></div>
116 </div>
117 </div>
118
119 <div class="hgroup">
120 <div class="hgroup-inline">
121 <div class="panel">
122 <h4 id="std-type">
123 std.type(x)
124 </h4>
125 </div>
126 <div style="clear: both"></div>
127 </div>
128 </div>
129 <div class="hgroup">
130 <div class="hgroup-inline">
131 <div class="panel">
132 <p>
133 <em>
134 Available since version 0.10.0.
135 </em>
136 </p>
137 <p>
138 Return a string that indicates the type of the value. The possible return values are:
139 "array", "boolean", "function", "null", "number", "object", and "string".
140 </p>
141 <p>
142 The following functions are also available and return a boolean:
143 <code>std.isArray(v)</code>, <code>std.isBoolean(v)</code>, <code>std.isFunction(v)</code>,
144 <code>std.isNumber(v)</code>, <code>std.isObject(v)</code>, and
145 <code>std.isString(v)</code>.
146 </p>
147
148 </div>
149 <div style="clear: both"></div>
150 </div>
151 </div>
152
153 <div class="hgroup">
154 <div class="hgroup-inline">
155 <div class="panel">
156 <h4 id="std-length">
157 std.length(x)
158 </h4>
159 </div>
160 <div style="clear: both"></div>
161 </div>
162 </div>
163 <div class="hgroup">
164 <div class="hgroup-inline">
165 <div class="panel">
166 <p>
167 <em>
168 Available since version 0.10.0.
169 </em>
170 </p>
171 <p>
172 Depending on the type of the value given, either returns the number of elements in the
173 array, the number of codepoints in the string, the number of parameters in the function, or
174 the number of fields in the object. Raises an error if given a primitive value, i.e.
175 <code>null</code>, <code>true</code> or <code>false</code>.
176 </p>
177
178 </div>
179 <div style="clear: both"></div>
180 </div>
181 </div>
182
183 <div class="hgroup">
184 <div class="hgroup-inline">
185 <div class="panel">
186 <h4 id="std-prune">
187 std.prune(a)
188 </h4>
189 </div>
190 <div style="clear: both"></div>
191 </div>
192 </div>
193 <div class="hgroup">
194 <div class="hgroup-inline">
195 <div class="panel">
196 <p>
197 <em>
198 Available since version 0.10.0.
199 </em>
200 </p>
201 <p>
202 Recursively remove all "empty" members of <code>a</code>. "Empty" is defined as zero
203 length `arrays`, zero length `objects`, or `null` values.
204 The argument <code>a</code> may have any type.
205 </p>
206
207 </div>
208 <div style="clear: both"></div>
209 </div>
210 </div>
211
212 <div class="hgroup">
213 <div class="hgroup-inline">
214 <div class="panel">
215 <h4 id="std-isNull">
216 std.isNull(x)
217 </h4>
218 </div>
219 <div style="clear: both"></div>
220 </div>
221 </div>
222 <div class="hgroup">
223 <div class="hgroup-inline">
224 <div class="panel">
225 <p>
226 <em>
227 Available since version 0.22.0.
228 </em>
229 </p>
230 <p>
231 Returns true if the given value is null, false otherwise.
232 </p>
233 <p>
234 Example: <code>std.isNull(null)</code> yields <code>true</code>.
235 </p>
236 <p>
237 Example: <code>std.isNull(42)</code> yields <code>false</code>.
238 </p>
239 <p>
240 Example: <code>std.isNull("string")</code> yields <code>false</code>.
241 </p>
242 </div>
243 <div style="clear: both"></div>
244 </div>
245 </div>
246
247
248 <div class="hgroup">
249 <div class="hgroup-inline">
250 <div class="panel">
251 <h3 id="math">
252 Mathematical Utilities
253 </h3>
254 </div>
255 <div style="clear: both"></div>
256 </div>
257 </div>
258 <div class="hgroup">
259 <div class="hgroup-inline">
260 <div class="panel">
261 <p>
262 The following mathematical functions are available:
263 </p>
264 <ul>
265 <ul><code>std.abs(n)</code></ul>
266 <ul><code>std.sign(n)</code></ul>
267 <ul><code>std.max(a, b)</code></ul>
268 <ul><code>std.min(a, b)</code></ul>
269 <ul><code>std.pow(x, n)</code></ul>
270 <ul><code>std.exp(x)</code></ul>
271 <ul><code>std.log(x)</code></ul>
272 <ul><code>std.log2(x)</code> (available since 0.21.0)</ul>
273 <ul><code>std.log10(x)</code> (available since 0.21.0)</ul>
274 <ul><code>std.exponent(x)</code></ul>
275 <ul><code>std.mantissa(x)</code></ul>
276 <ul><code>std.floor(x)</code></ul>
277 <ul><code>std.ceil(x)</code></ul>
278 <ul><code>std.sqrt(x)</code></ul>
279 <ul><code>std.sin(x)</code></ul>
280 <ul><code>std.cos(x)</code></ul>
281 <ul><code>std.tan(x)</code></ul>
282 <ul><code>std.asin(x)</code></ul>
283 <ul><code>std.acos(x)</code></ul>
284 <ul><code>std.atan(x)</code></ul>
285 <ul><code>std.atan2(y, x)</code> (available since 0.21.0)</ul>
286 <ul><code>std.deg2rad(x)</code> (available since 0.21.0)</ul>
287 <ul><code>std.rad2deg(x)</code> (available since 0.21.0)</ul>
288 <ul><code>std.hypot(a, b)</code> (available since 0.21.0)</ul>
289 <ul><code>std.round(x)</code> (available since 0.20.0)</ul>
290 <ul><code>std.isEven(x)</code> (available since 0.21.0)</ul>
291 <ul><code>std.isOdd(x)</code> (available since 0.21.0)</ul>
292 <ul><code>std.isInteger(x)</code> (available since 0.21.0)</ul>
293 <ul><code>std.isDecimal(x)</code> (available since 0.21.0)</ul>
294 </ul>
295 <p>
296 The constant <code>std.pi</code> is also available (since 0.21.0).
297 </p>
298 <p>
299 The function <code>std.mod(a, b)</code> is what the % operator is desugared to. It performs
300 modulo arithmetic if the left hand side is a number, or if the left hand side is a string,
301 it does Python-style string formatting with <code>std.format()</code>.
302 </p>
303 <p>
304 The functions <code>std.isEven(x)</code> and <code>std.isOdd(x)</code> use integral part of a
305 floating number to test for even or odd.
306 </p>
307 </div>
308 <div style="clear: both"></div>
309 </div>
310 </div>
311
312 <div class="hgroup">
313 <div class="hgroup-inline">
314 <div class="panel">
315 <h4 id="std-clamp">
316 std.clamp(x, minVal, maxVal)
317 </h4>
318 </div>
319 <div style="clear: both"></div>
320 </div>
321 </div>
322 <div class="hgroup">
323 <div class="hgroup-inline">
324 <div class="panel">
325 <p>
326 <em>
327 Available since version 0.15.0.
328 </em>
329 </p>
330 <p>
331 Clamp a value to fit within the range [<code>minVal</code>, <code>maxVal</code>].
332 Equivalent to <code>std.max(minVal, std.min(x, maxVal))</code>.
333 </p>
334 <p>
335 Example: <code>std.clamp(-3, 0, 5)</code> yields <code>0</code>.
336 </p>
337 <p>
338 Example: <code>std.clamp(4, 0, 5)</code> yields <code>4</code>.
339 </p>
340 <p>
341 Example: <code>std.clamp(7, 0, 5)</code> yields <code>5</code>.
342 </p>
343 </div>
344 <div style="clear: both"></div>
345 </div>
346 </div>
347
348
349 <div class="hgroup">
350 <div class="hgroup-inline">
351 <div class="panel">
352 <h3 id="assertions_debugging">
353 Assertions and Debugging
354 </h3>
355 </div>
356 <div style="clear: both"></div>
357 </div>
358 </div>
359
360 <div class="hgroup">
361 <div class="hgroup-inline">
362 <div class="panel">
363 <h4 id="std-assertEqual">
364 std.assertEqual(a, b)
365 </h4>
366 </div>
367 <div style="clear: both"></div>
368 </div>
369 </div>
370 <div class="hgroup">
371 <div class="hgroup-inline">
372 <div class="panel">
373 <p>
374 <em>
375 Available since version 0.10.0.
376 </em>
377 </p>
378 <p>
379 Ensure that <code>a == b</code>. Returns <code>true</code> or throws an error message.
380 </p>
381
382 </div>
383 <div style="clear: both"></div>
384 </div>
385 </div>
386
387
388 <div class="hgroup">
389 <div class="hgroup-inline">
390 <div class="panel">
391 <h3 id="string">
392 String Manipulation
393 </h3>
394 </div>
395 <div style="clear: both"></div>
396 </div>
397 </div>
398
399 <div class="hgroup">
400 <div class="hgroup-inline">
401 <div class="panel">
402 <h4 id="std-toString">
403 std.toString(a)
404 </h4>
405 </div>
406 <div style="clear: both"></div>
407 </div>
408 </div>
409 <div class="hgroup">
410 <div class="hgroup-inline">
411 <div class="panel">
412 <p>
413 <em>
414 Available since version 0.10.0.
415 </em>
416 </p>
417 <p>
418 Convert the given argument to a string.
419 </p>
420
421 </div>
422 <div style="clear: both"></div>
423 </div>
424 </div>
425
426 <div class="hgroup">
427 <div class="hgroup-inline">
428 <div class="panel">
429 <h4 id="std-codepoint">
430 std.codepoint(str)
431 </h4>
432 </div>
433 <div style="clear: both"></div>
434 </div>
435 </div>
436 <div class="hgroup">
437 <div class="hgroup-inline">
438 <div class="panel">
439 <p>
440 <em>
441 Available since version 0.10.0.
442 </em>
443 </p>
444 <p>
445 Returns the positive integer representing the unicode codepoint of the character in the
446 given single-character string. This function is the inverse of <code>std.char(n)</code>.
447 </p>
448
449 </div>
450 <div style="clear: both"></div>
451 </div>
452 </div>
453
454 <div class="hgroup">
455 <div class="hgroup-inline">
456 <div class="panel">
457 <h4 id="std-char">
458 std.char(n)
459 </h4>
460 </div>
461 <div style="clear: both"></div>
462 </div>
463 </div>
464 <div class="hgroup">
465 <div class="hgroup-inline">
466 <div class="panel">
467 <p>
468 <em>
469 Available since version 0.10.0.
470 </em>
471 </p>
472 <p>
473 Returns a string of length one whose only unicode codepoint has integer id <code>n</code>.
474 This function is the inverse of <code>std.codepoint(str)</code>.
475 </p>
476
477 </div>
478 <div style="clear: both"></div>
479 </div>
480 </div>
481
482 <div class="hgroup">
483 <div class="hgroup-inline">
484 <div class="panel">
485 <h4 id="std-substr">
486 std.substr(str, from, len)
487 </h4>
488 </div>
489 <div style="clear: both"></div>
490 </div>
491 </div>
492 <div class="hgroup">
493 <div class="hgroup-inline">
494 <div class="panel">
495 <p>
496 <em>
497 Available since version 0.10.0.
498 </em>
499 </p>
500 <p>
501 Returns a string that is the part of <code>str</code> that starts at offset <code>from</code>
502 and is <code>len</code> codepoints long. If the string <code>str</code> is shorter than
503 <code>from+len</code>, the suffix starting at position <code>from</code> will be returned.
504 </p>
505 <p>
506 The slice operator (e.g., <code>str[from:to]</code>) can also be used on strings, as an
507 alternative to this function. However, note that the slice operator takes a start and an
508 end index, but <code>std.substr</code> takes a start index and a length.
509 </p>
510
511 </div>
512 <div style="clear: both"></div>
513 </div>
514 </div>
515
516 <div class="hgroup">
517 <div class="hgroup-inline">
518 <div class="panel">
519 <h4 id="std-findSubstr">
520 std.findSubstr(pat, str)
521 </h4>
522 </div>
523 <div style="clear: both"></div>
524 </div>
525 </div>
526 <div class="hgroup">
527 <div class="hgroup-inline">
528 <div class="panel">
529 <p>
530 <em>
531 Available since version 0.10.0.
532 </em>
533 </p>
534 <p>
535 Returns an array that contains the indexes of all occurrences of <code>pat</code> in
536 <code>str</code>.
537 </p>
538
539 </div>
540 <div style="clear: both"></div>
541 </div>
542 </div>
543
544 <div class="hgroup">
545 <div class="hgroup-inline">
546 <div class="panel">
547 <h4 id="std-startsWith">
548 std.startsWith(a, b)
549 </h4>
550 </div>
551 <div style="clear: both"></div>
552 </div>
553 </div>
554 <div class="hgroup">
555 <div class="hgroup-inline">
556 <div class="panel">
557 <p>
558 <em>
559 Available since version 0.10.0.
560 </em>
561 </p>
562 <p>
563 Returns whether the string a is prefixed by the string b.
564 </p>
565
566 </div>
567 <div style="clear: both"></div>
568 </div>
569 </div>
570
571 <div class="hgroup">
572 <div class="hgroup-inline">
573 <div class="panel">
574 <h4 id="std-endsWith">
575 std.endsWith(a, b)
576 </h4>
577 </div>
578 <div style="clear: both"></div>
579 </div>
580 </div>
581 <div class="hgroup">
582 <div class="hgroup-inline">
583 <div class="panel">
584 <p>
585 <em>
586 Available since version 0.10.0.
587 </em>
588 </p>
589 <p>
590 Returns whether the string a is suffixed by the string b.
591 </p>
592
593 </div>
594 <div style="clear: both"></div>
595 </div>
596 </div>
597
598 <div class="hgroup">
599 <div class="hgroup-inline">
600 <div class="panel">
601 <h4 id="std-stripChars">
602 std.stripChars(str, chars)
603 </h4>
604 </div>
605 <div style="clear: both"></div>
606 </div>
607 </div>
608 <div class="hgroup">
609 <div class="hgroup-inline">
610 <div class="panel">
611 <p>
612 <em>
613 Available since version 0.15.0.
614 </em>
615 </p>
616 <p>
617 Removes characters <code>chars</code> from the beginning and from the end of <code>str</code>.
618 </p>
619 <p>
620 Example: <code>std.stripChars(" test test test ", " ")</code> yields <code>"test test test"</code>.
621 </p>
622 <p>
623 Example: <code>std.stripChars("aaabbbbcccc", "ac")</code> yields <code>"bbbb"</code>.
624 </p>
625 <p>
626 Example: <code>std.stripChars("cacabbbbaacc", "ac")</code> yields <code>"bbbb"</code>.
627 </p>
628 </div>
629 <div style="clear: both"></div>
630 </div>
631 </div>
632
633 <div class="hgroup">
634 <div class="hgroup-inline">
635 <div class="panel">
636 <h4 id="std-lstripChars">
637 std.lstripChars(str, chars)
638 </h4>
639 </div>
640 <div style="clear: both"></div>
641 </div>
642 </div>
643 <div class="hgroup">
644 <div class="hgroup-inline">
645 <div class="panel">
646 <p>
647 <em>
648 Available since version 0.15.0.
649 </em>
650 </p>
651 <p>
652 Removes characters <code>chars</code> from the beginning of <code>str</code>.
653 </p>
654 <p>
655 Example: <code>std.lstripChars(" test test test ", " ")</code> yields <code>"test test test "</code>.
656 </p>
657 <p>
658 Example: <code>std.lstripChars("aaabbbbcccc", "ac")</code> yields <code>"bbbbcccc"</code>.
659 </p>
660 <p>
661 Example: <code>std.lstripChars("cacabbbbaacc", "ac")</code> yields <code>"bbbbaacc"</code>.
662 </p>
663 </div>
664 <div style="clear: both"></div>
665 </div>
666 </div>
667
668 <div class="hgroup">
669 <div class="hgroup-inline">
670 <div class="panel">
671 <h4 id="std-rstripChars">
672 std.rstripChars(str, chars)
673 </h4>
674 </div>
675 <div style="clear: both"></div>
676 </div>
677 </div>
678 <div class="hgroup">
679 <div class="hgroup-inline">
680 <div class="panel">
681 <p>
682 <em>
683 Available since version 0.15.0.
684 </em>
685 </p>
686 <p>
687 Removes characters <code>chars</code> from the end of <code>str</code>.
688 </p>
689 <p>
690 Example: <code>std.rstripChars(" test test test ", " ")</code> yields <code>" test test test"</code>.
691 </p>
692 <p>
693 Example: <code>std.rstripChars("aaabbbbcccc", "ac")</code> yields <code>"aaabbbb"</code>.
694 </p>
695 <p>
696 Example: <code>std.rstripChars("cacabbbbaacc", "ac")</code> yields <code>"cacabbbb"</code>.
697 </p>
698 </div>
699 <div style="clear: both"></div>
700 </div>
701 </div>
702
703 <div class="hgroup">
704 <div class="hgroup-inline">
705 <div class="panel">
706 <h4 id="std-split">
707 std.split(str, c)
708 </h4>
709 </div>
710 <div style="clear: both"></div>
711 </div>
712 </div>
713 <div class="hgroup">
714 <div class="hgroup-inline">
715 <div class="panel">
716 <p>
717 <em>
718 Available since version 0.10.0.
719 </em>
720 </p>
721 <p>
722 Split the string <code>str</code> into an array of strings, divided by the string
723 <code>c</code>.
724 </p>
725 <p>
726 Note: Versions up to and including 0.18.0 require <code>c</code> to be a single character.
727 </p>
728 <p>
729 Example: <code>std.split("foo/_bar", "/_")</code> yields <code>[ "foo", "bar" ]</code>.
730 </p>
731 <p>
732 Example: <code>std.split("/_foo/_bar", "/_")</code> yields <code>[ "", "foo", "bar" ]</code>.
733 </p>
734 </div>
735 <div style="clear: both"></div>
736 </div>
737 </div>
738
739 <div class="hgroup">
740 <div class="hgroup-inline">
741 <div class="panel">
742 <h4 id="std-splitLimit">
743 std.splitLimit(str, c, maxsplits)
744 </h4>
745 </div>
746 <div style="clear: both"></div>
747 </div>
748 </div>
749 <div class="hgroup">
750 <div class="hgroup-inline">
751 <div class="panel">
752 <p>
753 <em>
754 Available since version 0.10.0.
755 </em>
756 </p>
757 <p>
758 As <code>std.split(str, c)</code> but will stop after <code>maxsplits</code> splits, thereby the largest
759 array it will return has length <code>maxsplits + 1</code>. A limit of <code>-1</code> means unlimited.
760 </p>
761 <p>
762 Note: Versions up to and including 0.18.0 require <code>c</code> to be a single character.
763 </p>
764 <p>
765 Example: <code>std.splitLimit("foo/_bar", "/_", 1)</code> yields <code>[ "foo", "bar" ]</code>.
766 </p>
767 <p>
768 Example: <code>std.splitLimit("/_foo/_bar", "/_", 1)</code> yields <code>[ "", "foo/_bar" ]</code>.
769 </p>
770 </div>
771 <div style="clear: both"></div>
772 </div>
773 </div>
774
775 <div class="hgroup">
776 <div class="hgroup-inline">
777 <div class="panel">
778 <h4 id="std-splitLimitR">
779 std.splitLimitR(str, c, maxsplits)
780 </h4>
781 </div>
782 <div style="clear: both"></div>
783 </div>
784 </div>
785 <div class="hgroup">
786 <div class="hgroup-inline">
787 <div class="panel">
788 <p>
789 <em>
790 Available since version 0.19.0.
791 </em>
792 </p>
793 <p>
794 As <code>std.splitLimit(str, c, maxsplits)</code> but will split from right to left.
795 </p>
796 <p>
797 Example: <code>std.splitLimitR("/_foo/_bar", "/_", 1)</code> yields <code>[ "/_foo", "bar" ]</code>.
798 </p>
799 </div>
800 <div style="clear: both"></div>
801 </div>
802 </div>
803
804 <div class="hgroup">
805 <div class="hgroup-inline">
806 <div class="panel">
807 <h4 id="std-strReplace">
808 std.strReplace(str, from, to)
809 </h4>
810 </div>
811 <div style="clear: both"></div>
812 </div>
813 </div>
814 <div class="hgroup">
815 <div class="hgroup-inline">
816 <div class="panel">
817 <p>
818 <em>
819 Available since version 0.10.0.
820 </em>
821 </p>
822 <p>
823 Returns a copy of the string in which all occurrences of string <code>from</code> have been
824 replaced with string <code>to</code>.
825 </p>
826 <p>
827 Example: <code>std.strReplace('I like to skate with my skateboard', 'skate', 'surf')</code> yields <code>"I like to surf with my surfboard"</code>.
828 </p>
829 </div>
830 <div style="clear: both"></div>
831 </div>
832 </div>
833
834 <div class="hgroup">
835 <div class="hgroup-inline">
836 <div class="panel">
837 <h4 id="std-isEmpty">
838 std.isEmpty(str)
839 </h4>
840 </div>
841 <div style="clear: both"></div>
842 </div>
843 </div>
844 <div class="hgroup">
845 <div class="hgroup-inline">
846 <div class="panel">
847 <p>
848 <em>
849 Available since version 0.20.0.
850 </em>
851 </p>
852 <p>
853 Returns true if the given string is of zero length.
854 </p>
855
856 </div>
857 <div style="clear: both"></div>
858 </div>
859 </div>
860
861 <div class="hgroup">
862 <div class="hgroup-inline">
863 <div class="panel">
864 <h4 id="std-trim">
865 std.trim(str)
866 </h4>
867 </div>
868 <div style="clear: both"></div>
869 </div>
870 </div>
871 <div class="hgroup">
872 <div class="hgroup-inline">
873 <div class="panel">
874 <p>
875 <em>
876 Available since version 0.21.0.
877 </em>
878 </p>
879 <p>
880 Returns a copy of string after eliminating leading and trailing whitespaces.
881 </p>
882
883 </div>
884 <div style="clear: both"></div>
885 </div>
886 </div>
887
888 <div class="hgroup">
889 <div class="hgroup-inline">
890 <div class="panel">
891 <h4 id="std-equalsIgnoreCase">
892 std.equalsIgnoreCase(str1, str2)
893 </h4>
894 </div>
895 <div style="clear: both"></div>
896 </div>
897 </div>
898 <div class="hgroup">
899 <div class="hgroup-inline">
900 <div class="panel">
901 <p>
902 <em>
903 Available since version 0.21.0.
904 </em>
905 </p>
906 <p>
907 Returns true if the the given <code>str1</code> is equal to <code>str2</code> by doing case insensitive comparison, false otherwise.
908 </p>
909
910 </div>
911 <div style="clear: both"></div>
912 </div>
913 </div>
914
915 <div class="hgroup">
916 <div class="hgroup-inline">
917 <div class="panel">
918 <h4 id="std-asciiUpper">
919 std.asciiUpper(str)
920 </h4>
921 </div>
922 <div style="clear: both"></div>
923 </div>
924 </div>
925 <div class="hgroup">
926 <div class="hgroup-inline">
927 <div class="panel">
928 <p>
929 <em>
930 Available since version 0.10.0.
931 </em>
932 </p>
933 <p>
934 Returns a copy of the string in which all ASCII letters are capitalized.
935 </p>
936 <p>
937 Example: <code>std.asciiUpper('100 Cats!')</code> yields <code>"100 CATS!"</code>.
938 </p>
939 </div>
940 <div style="clear: both"></div>
941 </div>
942 </div>
943
944 <div class="hgroup">
945 <div class="hgroup-inline">
946 <div class="panel">
947 <h4 id="std-asciiLower">
948 std.asciiLower(str)
949 </h4>
950 </div>
951 <div style="clear: both"></div>
952 </div>
953 </div>
954 <div class="hgroup">
955 <div class="hgroup-inline">
956 <div class="panel">
957 <p>
958 <em>
959 Available since version 0.10.0.
960 </em>
961 </p>
962 <p>
963 Returns a copy of the string in which all ASCII letters are lower cased.
964 </p>
965 <p>
966 Example: <code>std.asciiLower('100 Cats!')</code> yields <code>"100 cats!"</code>.
967 </p>
968 </div>
969 <div style="clear: both"></div>
970 </div>
971 </div>
972
973 <div class="hgroup">
974 <div class="hgroup-inline">
975 <div class="panel">
976 <h4 id="std-stringChars">
977 std.stringChars(str)
978 </h4>
979 </div>
980 <div style="clear: both"></div>
981 </div>
982 </div>
983 <div class="hgroup">
984 <div class="hgroup-inline">
985 <div class="panel">
986 <p>
987 <em>
988 Available since version 0.10.0.
989 </em>
990 </p>
991 <p>
992 Split the string <code>str</code> into an array of strings, each containing a single
993 codepoint.
994 </p>
995 <p>
996 Example: <code>std.stringChars("foo")</code> yields <code>[ "f", "o", "o" ]</code>.
997 </p>
998 </div>
999 <div style="clear: both"></div>
1000 </div>
1001 </div>
1002
1003 <div class="hgroup">
1004 <div class="hgroup-inline">
1005 <div class="panel">
1006 <h4 id="std-format">
1007 std.format(str, vals)
1008 </h4>
1009 </div>
1010 <div style="clear: both"></div>
1011 </div>
1012 </div>
1013 <div class="hgroup">
1014 <div class="hgroup-inline">
1015 <div class="panel">
1016 <p>
1017 <em>
1018 Available since version 0.10.0.
1019 </em>
1020 </p>
1021 <p>
1022 Format the string <code>str</code> using the values in <code>vals</code>. The values can be
1023 an array, an object, or in other cases are treated as if they were provided in a singleton
1024 array. The string formatting follows the <a
1025 href="https://docs.python.org/2/library/stdtypes.html#string-formatting">same rules</a> as
1026 Python. The <code>%</code> operator can be used as a shorthand for this function.
1027 </p>
1028 <p>
1029 Example: <code>std.format("Hello %03d", 12)</code> yields <code>"Hello 012"</code>.
1030 </p>
1031 <p>
1032 Example: <code>"Hello %03d" % 12</code> yields <code>"Hello 012"</code>.
1033 </p>
1034 <p>
1035 Example: <code>"Hello %s, age %d" % ["Foo", 25]</code> yields <code>"Hello Foo, age 25"</code>.
1036 </p>
1037 <p>
1038 Example: <code>"Hello %(name)s, age %(age)d" % {age: 25, name: "Foo"}</code> yields <code>"Hello Foo, age 25"</code>.
1039 </p>
1040 </div>
1041 <div style="clear: both"></div>
1042 </div>
1043 </div>
1044
1045 <div class="hgroup">
1046 <div class="hgroup-inline">
1047 <div class="panel">
1048 <h4 id="std-escapeStringBash">
1049 std.escapeStringBash(str)
1050 </h4>
1051 </div>
1052 <div style="clear: both"></div>
1053 </div>
1054 </div>
1055 <div class="hgroup">
1056 <div class="hgroup-inline">
1057 <div class="panel">
1058 <p>
1059 <em>
1060 Available since version 0.10.0.
1061 </em>
1062 </p>
1063 <p>
1064 Wrap <code>str</code> in single quotes, and escape any single quotes within <code>str</code>
1065 by changing them to a sequence <tt>'"'"'</tt>. This allows injection of arbitrary strings
1066 as arguments of commands in bash scripts.
1067 </p>
1068
1069 </div>
1070 <div style="clear: both"></div>
1071 </div>
1072 </div>
1073
1074 <div class="hgroup">
1075 <div class="hgroup-inline">
1076 <div class="panel">
1077 <h4 id="std-escapeStringDollars">
1078 std.escapeStringDollars(str)
1079 </h4>
1080 </div>
1081 <div style="clear: both"></div>
1082 </div>
1083 </div>
1084 <div class="hgroup">
1085 <div class="hgroup-inline">
1086 <div class="panel">
1087 <p>
1088 <em>
1089 Available since version 0.10.0.
1090 </em>
1091 </p>
1092 <p>
1093 Convert $ to $$ in <code>str</code>. This allows injection of arbitrary strings into
1094 systems that use $ for string interpolation (like Terraform).
1095 </p>
1096
1097 </div>
1098 <div style="clear: both"></div>
1099 </div>
1100 </div>
1101
1102 <div class="hgroup">
1103 <div class="hgroup-inline">
1104 <div class="panel">
1105 <h4 id="std-escapeStringJson">
1106 std.escapeStringJson(str)
1107 </h4>
1108 </div>
1109 <div style="clear: both"></div>
1110 </div>
1111 </div>
1112 <div class="hgroup">
1113 <div class="hgroup-inline">
1114 <div class="panel">
1115 <p>
1116 <em>
1117 Available since version 0.10.0.
1118 </em>
1119 </p>
1120 <p>
1121 Convert <code>str</code> to allow it to be embedded in a JSON representation, within a
1122 string. This adds quotes, escapes backslashes, and escapes unprintable characters.
1123 </p>
1124 <p>
1125 Example: <code>local description = "Multiline\nc:\\path";
1126 "{name: %s}" % std.escapeStringJson(description)</code> yields <code>"{name: \"Multiline\\nc:\\\\path\"}"</code>.
1127 </p>
1128 </div>
1129 <div style="clear: both"></div>
1130 </div>
1131 </div>
1132
1133 <div class="hgroup">
1134 <div class="hgroup-inline">
1135 <div class="panel">
1136 <h4 id="std-escapeStringPython">
1137 std.escapeStringPython(str)
1138 </h4>
1139 </div>
1140 <div style="clear: both"></div>
1141 </div>
1142 </div>
1143 <div class="hgroup">
1144 <div class="hgroup-inline">
1145 <div class="panel">
1146 <p>
1147 <em>
1148 Available since version 0.10.0.
1149 </em>
1150 </p>
1151 <p>
1152 Convert <code>str</code> to allow it to be embedded in Python. This is an alias for
1153 <code>std.escapeStringJson</code>.
1154 </p>
1155
1156 </div>
1157 <div style="clear: both"></div>
1158 </div>
1159 </div>
1160
1161 <div class="hgroup">
1162 <div class="hgroup-inline">
1163 <div class="panel">
1164 <h4 id="std-escapeStringXml">
1165 std.escapeStringXml(str)
1166 </h4>
1167 </div>
1168 <div style="clear: both"></div>
1169 </div>
1170 </div>
1171 <div class="hgroup">
1172 <div class="hgroup-inline">
1173 <div class="panel">
1174 <p>
1175 <em>
1176 Available since version 0.10.0.
1177 </em>
1178 </p>
1179 <p>
1180 Convert <code>str</code> to allow it to be embedded in XML (or HTML). The following replacements are made:
1181 <pre>
1182 {
1183 "&lt;": "&amp;lt;",
1184 "&gt;": "&amp;gt;",
1185 "&amp;": "&amp;amp;",
1186 "\&quot;": "&amp;quot;",
1187 "&apos;": "&amp;apos;",
1188 }
1189 </pre>
1190 </p>
1191
1192 </div>
1193 <div style="clear: both"></div>
1194 </div>
1195 </div>
1196
1197
1198 <div class="hgroup">
1199 <div class="hgroup-inline">
1200 <div class="panel">
1201 <h3 id="parsing">
1202 Parsing
1203 </h3>
1204 </div>
1205 <div style="clear: both"></div>
1206 </div>
1207 </div>
1208
1209 <div class="hgroup">
1210 <div class="hgroup-inline">
1211 <div class="panel">
1212 <h4 id="std-parseInt">
1213 std.parseInt(str)
1214 </h4>
1215 </div>
1216 <div style="clear: both"></div>
1217 </div>
1218 </div>
1219 <div class="hgroup">
1220 <div class="hgroup-inline">
1221 <div class="panel">
1222 <p>
1223 <em>
1224 Available since version 0.10.0.
1225 </em>
1226 </p>
1227 <p>
1228 Parses a signed decimal integer from the input string.
1229 </p>
1230 <p>
1231 Example: <code>std.parseInt("123")</code> yields <code>123</code>.
1232 </p>
1233 <p>
1234 Example: <code>std.parseInt("-123")</code> yields <code>-123</code>.
1235 </p>
1236 </div>
1237 <div style="clear: both"></div>
1238 </div>
1239 </div>
1240
1241 <div class="hgroup">
1242 <div class="hgroup-inline">
1243 <div class="panel">
1244 <h4 id="std-parseOctal">
1245 std.parseOctal(str)
1246 </h4>
1247 </div>
1248 <div style="clear: both"></div>
1249 </div>
1250 </div>
1251 <div class="hgroup">
1252 <div class="hgroup-inline">
1253 <div class="panel">
1254 <p>
1255 <em>
1256 Available since version 0.10.0.
1257 </em>
1258 </p>
1259 <p>
1260 Parses an unsigned octal integer from the input string. Initial zeroes are tolerated.
1261 </p>
1262 <p>
1263 Example: <code>std.parseOctal("755")</code> yields <code>493</code>.
1264 </p>
1265 </div>
1266 <div style="clear: both"></div>
1267 </div>
1268 </div>
1269
1270 <div class="hgroup">
1271 <div class="hgroup-inline">
1272 <div class="panel">
1273 <h4 id="std-parseHex">
1274 std.parseHex(str)
1275 </h4>
1276 </div>
1277 <div style="clear: both"></div>
1278 </div>
1279 </div>
1280 <div class="hgroup">
1281 <div class="hgroup-inline">
1282 <div class="panel">
1283 <p>
1284 <em>
1285 Available since version 0.10.0.
1286 </em>
1287 </p>
1288 <p>
1289 Parses an unsigned hexadecimal integer, from the input string. Case insensitive.
1290 </p>
1291 <p>
1292 Example: <code>std.parseHex("ff")</code> yields <code>255</code>.
1293 </p>
1294 </div>
1295 <div style="clear: both"></div>
1296 </div>
1297 </div>
1298
1299 <div class="hgroup">
1300 <div class="hgroup-inline">
1301 <div class="panel">
1302 <h4 id="std-parseJson">
1303 std.parseJson(str)
1304 </h4>
1305 </div>
1306 <div style="clear: both"></div>
1307 </div>
1308 </div>
1309 <div class="hgroup">
1310 <div class="hgroup-inline">
1311 <div class="panel">
1312 <p>
1313 <em>
1314 Available since version 0.13.0.
1315 </em>
1316 </p>
1317 <p>
1318 Parses a JSON string.
1319 </p>
1320 <p>
1321 Example: <code>std.parseJson('{"foo": "bar"}')</code> yields <code>{ "foo": "bar" }</code>.
1322 </p>
1323 </div>
1324 <div style="clear: both"></div>
1325 </div>
1326 </div>
1327
1328 <div class="hgroup">
1329 <div class="hgroup-inline">
1330 <div class="panel">
1331 <h4 id="std-parseYaml">
1332 std.parseYaml(str)
1333 </h4>
1334 </div>
1335 <div style="clear: both"></div>
1336 </div>
1337 </div>
1338 <div class="hgroup">
1339 <div class="hgroup-inline">
1340 <div class="panel">
1341 <p>
1342 <em>
1343 Available since version 0.18.0.
1344 </em>
1345 </p>
1346 <p>
1347 Parses a YAML string. This is provided as a "best-effort" mechanism and should not be relied on to provide
1348 a fully standards compliant YAML parser. YAML is a superset of JSON, consequently "downcasting" or
1349 manifestation of YAML into JSON or Jsonnet values will only succeed when using the subset of YAML that is
1350 compatible with JSON. The parser does not support YAML documents with scalar values at the root. The
1351 root node of a YAML document must start with either a YAML sequence or map to be successfully parsed.
1352 </p>
1353 <p>
1354 Example: <code>std.parseYaml('foo: bar')</code> yields <code>{ "foo": "bar" }</code>.
1355 </p>
1356 </div>
1357 <div style="clear: both"></div>
1358 </div>
1359 </div>
1360
1361 <div class="hgroup">
1362 <div class="hgroup-inline">
1363 <div class="panel">
1364 <h4 id="std-encodeUTF8">
1365 std.encodeUTF8(str)
1366 </h4>
1367 </div>
1368 <div style="clear: both"></div>
1369 </div>
1370 </div>
1371 <div class="hgroup">
1372 <div class="hgroup-inline">
1373 <div class="panel">
1374 <p>
1375 <em>
1376 Available since version 0.13.0.
1377 </em>
1378 </p>
1379 <p>
1380 Encode a string using <a href="https://en.wikipedia.org/wiki/UTF-8">UTF8</a>. Returns an array of numbers
1381 representing bytes.
1382 </p>
1383
1384 </div>
1385 <div style="clear: both"></div>
1386 </div>
1387 </div>
1388
1389 <div class="hgroup">
1390 <div class="hgroup-inline">
1391 <div class="panel">
1392 <h4 id="std-decodeUTF8">
1393 std.decodeUTF8(arr)
1394 </h4>
1395 </div>
1396 <div style="clear: both"></div>
1397 </div>
1398 </div>
1399 <div class="hgroup">
1400 <div class="hgroup-inline">
1401 <div class="panel">
1402 <p>
1403 <em>
1404 Available since version 0.13.0.
1405 </em>
1406 </p>
1407 <p>
1408 Decode an array of numbers representing bytes using <a href="https://en.wikipedia.org/wiki/UTF-8">UTF8</a>.
1409 Returns a string.
1410 </p>
1411
1412 </div>
1413 <div style="clear: both"></div>
1414 </div>
1415 </div>
1416
1417
1418 <div class="hgroup">
1419 <div class="hgroup-inline">
1420 <div class="panel">
1421 <h3 id="manifestation">
1422 Manifestation
1423 </h3>
1424 </div>
1425 <div style="clear: both"></div>
1426 </div>
1427 </div>
1428
1429 <div class="hgroup">
1430 <div class="hgroup-inline">
1431 <div class="panel">
1432 <h4 id="std-manifestIni">
1433 std.manifestIni(ini)
1434 </h4>
1435 </div>
1436 <div style="clear: both"></div>
1437 </div>
1438 </div>
1439 <div class="hgroup">
1440 <div class="hgroup-inline">
1441 <div class="panel">
1442 <p>
1443 <em>
1444 Available since version 0.10.0.
1445 </em>
1446 </p>
1447 <p>
1448 Convert the given structure to a string in <a href="https://en.wikipedia.org/wiki/INI_file">INI format</a>. This
1449 allows using Jsonnet's
1450 object model to build a configuration to be consumed by an application expecting an INI
1451 file. The data is in the form of a set of sections, each containing a key/value mapping.
1452 These examples should make it clear:
1453 </p>
1454 <pre>{
1455 main: { a: "1", b: "2" },
1456 sections: {
1457 s1: {x: "11", y: "22", z: "33"},
1458 s2: {p: "yes", q: ""},
1459 empty: {},
1460 }
1461 }</pre>
1462 <p>
1463 Yields a string containing this INI file:
1464 </p>
1465 <pre>a = 1
1466 b = 2
1467 [empty]
1468 [s1]
1469 x = 11
1470 y = 22
1471 z = 33
1472 [s2]
1473 p = yes
1474 q =</pre>
1475
1476 </div>
1477 <div style="clear: both"></div>
1478 </div>
1479 </div>
1480
1481 <div class="hgroup">
1482 <div class="hgroup-inline">
1483 <div class="panel">
1484 <h4 id="std-manifestPython">
1485 std.manifestPython(v)
1486 </h4>
1487 </div>
1488 <div style="clear: both"></div>
1489 </div>
1490 </div>
1491 <div class="hgroup">
1492 <div class="hgroup-inline">
1493 <div class="panel">
1494 <p>
1495 <em>
1496 Available since version 0.10.0.
1497 </em>
1498 </p>
1499 <p>
1500 Convert the given value to a JSON-like form that is compatible with Python. The chief
1501 differences are True / False / None instead of true / false / null.
1502 </p>
1503 <pre>{
1504 b: ["foo", "bar"],
1505 c: true,
1506 d: null,
1507 e: { f1: false, f2: 42 },
1508 }</pre>
1509 <p>
1510 Yields a string containing Python code like:
1511 </p>
1512 <pre>{
1513 "b": ["foo", "bar"],
1514 "c": True,
1515 "d": None,
1516 "e": {"f1": False, "f2": 42}
1517 }</pre>
1518
1519 </div>
1520 <div style="clear: both"></div>
1521 </div>
1522 </div>
1523
1524 <div class="hgroup">
1525 <div class="hgroup-inline">
1526 <div class="panel">
1527 <h4 id="std-manifestPythonVars">
1528 std.manifestPythonVars(conf)
1529 </h4>
1530 </div>
1531 <div style="clear: both"></div>
1532 </div>
1533 </div>
1534 <div class="hgroup">
1535 <div class="hgroup-inline">
1536 <div class="panel">
1537 <p>
1538 <em>
1539 Available since version 0.10.0.
1540 </em>
1541 </p>
1542 <p>
1543 Convert the given object to a JSON-like form that is compatible with Python. The key
1544 difference to <code>std.manifestPython</code> is that the top level is represented as a list
1545 of Python global variables.
1546 </p>
1547 <pre>{
1548 b: ["foo", "bar"],
1549 c: true,
1550 d: null,
1551 e: { f1: false, f2: 42 },
1552 }</pre>
1553 <p>
1554 Yields a string containing this Python code:
1555 </p>
1556 <pre>b = ["foo", "bar"]
1557 c = True
1558 d = None
1559 e = {"f1": False, "f2": 42}</pre>
1560
1561 </div>
1562 <div style="clear: both"></div>
1563 </div>
1564 </div>
1565
1566 <div class="hgroup">
1567 <div class="hgroup-inline">
1568 <div class="panel">
1569 <h4 id="std-manifestJsonEx">
1570 std.manifestJsonEx(value, indent, newline, key_val_sep)
1571 </h4>
1572 </div>
1573 <div style="clear: both"></div>
1574 </div>
1575 </div>
1576 <div class="hgroup">
1577 <div class="hgroup-inline">
1578 <div class="panel">
1579 <p>
1580 <em>
1581 Available since version 0.10.0.
1582 </em>
1583 </p>
1584 <p>
1585 Convert the given object to a JSON form. <code>indent</code> is a string containing
1586 one or more whitespaces that are used for indentation. <code>newline</code> is
1587 by default <code>\n</code> and is inserted where a newline would normally be used
1588 to break long lines. <code>key_val_sep</code> is used to separate the key and value
1589 of an object field:
1590 </p>
1591 <p>
1592 Example:
1593 </p><pre>std.manifestJsonEx(
1594 {
1595 x: [1, 2, 3, true, false, null,
1596 "string\nstring"],
1597 y: { a: 1, b: 2, c: [1, 2] },
1598 }, " ")</pre><p>
1599 Yields a string containing this JSON:
1600 </p><pre>{
1601 "x": [
1602 1,
1603 2,
1604 3,
1605 true,
1606 false,
1607 null,
1608 "string\nstring"
1609 ],
1610 "y": {
1611 "a": 1,
1612 "b": 2,
1613 "c": [
1614 1,
1615 2
1616 ]
1617 }
1618 }</pre>
1619 <p>
1620 Example:
1621 </p><pre>std.manifestJsonEx(
1622 {
1623 x: [1, 2, "string\nstring"],
1624 y: { a: 1, b: [1, 2] },
1625 }, "", " ", " : ")</pre><p>
1626 Yields a string containing this JSON:
1627 </p><pre>{ "x" : [ 1, 2, "string\nstring" ], "y" : { "a" : 1, "b" : [ 1, 2 ] } }</pre>
1628 </div>
1629 <div style="clear: both"></div>
1630 </div>
1631 </div>
1632
1633 <div class="hgroup">
1634 <div class="hgroup-inline">
1635 <div class="panel">
1636 <h4 id="std-manifestJson">
1637 std.manifestJson(value)
1638 </h4>
1639 </div>
1640 <div style="clear: both"></div>
1641 </div>
1642 </div>
1643 <div class="hgroup">
1644 <div class="hgroup-inline">
1645 <div class="panel">
1646 <p>
1647 <em>
1648 Available since version 0.10.0.
1649 </em>
1650 </p>
1651 <p>
1652 Convert the given object to a JSON form. Under the covers,
1653 it calls <code>std.manifestJsonEx</code> with a 4-space indent:
1654 </p>
1655 <p>
1656 Example:
1657 </p><pre>std.manifestJson(
1658 {
1659 x: [1, 2, 3, true, false, null,
1660 "string\nstring"],
1661 y: { a: 1, b: 2, c: [1, 2] },
1662 })</pre><p>
1663 Yields a string containing this JSON:
1664 </p><pre>{
1665 "x": [
1666 1,
1667 2,
1668 3,
1669 true,
1670 false,
1671 null,
1672 "string\nstring"
1673 ],
1674 "y": {
1675 "a": 1,
1676 "b": 2,
1677 "c": [
1678 1,
1679 2
1680 ]
1681 }
1682 }</pre>
1683 </div>
1684 <div style="clear: both"></div>
1685 </div>
1686 </div>
1687
1688 <div class="hgroup">
1689 <div class="hgroup-inline">
1690 <div class="panel">
1691 <h4 id="std-manifestJsonMinified">
1692 std.manifestJsonMinified(value)
1693 </h4>
1694 </div>
1695 <div style="clear: both"></div>
1696 </div>
1697 </div>
1698 <div class="hgroup">
1699 <div class="hgroup-inline">
1700 <div class="panel">
1701 <p>
1702 <em>
1703 Available since version 0.18.0.
1704 </em>
1705 </p>
1706 <p>
1707 Convert the given object to a minified JSON form. Under the covers,
1708 it calls <code>std.manifestJsonEx</code>:
1709 </p>
1710 <p>
1711 Example:
1712 </p><pre>std.manifestJsonMinified(
1713 {
1714 x: [1, 2, 3, true, false, null,
1715 "string\nstring"],
1716 y: { a: 1, b: 2, c: [1, 2] },
1717 })</pre><p>
1718 Yields a string containing this JSON:
1719 </p><pre>{"x":[1,2,3,true,false,null,"string\nstring"],"y":{"a":1,"b":2,"c":[1,2]}}</pre>
1720 </div>
1721 <div style="clear: both"></div>
1722 </div>
1723 </div>
1724
1725 <div class="hgroup">
1726 <div class="hgroup-inline">
1727 <div class="panel">
1728 <h4 id="std-manifestYamlDoc">
1729 std.manifestYamlDoc(value, indent_array_in_object=false, quote_keys=true)
1730 </h4>
1731 </div>
1732 <div style="clear: both"></div>
1733 </div>
1734 </div>
1735 <div class="hgroup">
1736 <div class="hgroup-inline">
1737 <div class="panel">
1738 <p>
1739 <em>
1740 Available since version 0.10.0.
1741 </em>
1742 </p>
1743 <p>
1744 Convert the given value to a YAML form. Note that <code>std.manifestJson</code> could also
1745 be used for this purpose, because any JSON is also valid YAML. But this function will
1746 produce more canonical-looking YAML.
1747 </p>
1748 <pre>std.manifestYamlDoc(
1749 {
1750 x: [1, 2, 3, true, false, null,
1751 "string\nstring\n"],
1752 y: { a: 1, b: 2, c: [1, 2] },
1753 },
1754 indent_array_in_object=false)</pre>
1755 <p>
1756 Yields a string containing this YAML:
1757 </p>
1758 <pre>"x":
1759 - 1
1760 - 2
1761 - 3
1762 - true
1763 - false
1764 - null
1765 - |
1766 string
1767 string
1768 "y":
1769 "a": 1
1770 "b": 2
1771 "c":
1772 - 1
1773 - 2</pre>
1774 <p>
1775 The <code>indent_array_in_object</code> param adds additional indentation which some people
1776 may find easier to read.
1777 </p>
1778 <p>
1779 The <code>quote_keys</code> parameter controls whether YAML identifiers are always quoted
1780 or only when necessary.
1781 </p>
1782
1783 </div>
1784 <div style="clear: both"></div>
1785 </div>
1786 </div>
1787
1788 <div class="hgroup">
1789 <div class="hgroup-inline">
1790 <div class="panel">
1791 <h4 id="std-manifestYamlStream">
1792 std.manifestYamlStream(value, indent_array_in_object=false, c_document_end=false, quote_keys=true)
1793 </h4>
1794 </div>
1795 <div style="clear: both"></div>
1796 </div>
1797 </div>
1798 <div class="hgroup">
1799 <div class="hgroup-inline">
1800 <div class="panel">
1801 <p>
1802 <em>
1803 Available since version 0.10.0.
1804 </em>
1805 </p>
1806 <p>
1807 Given an array of values, emit a YAML "stream", which is a sequence of documents separated
1808 by <code>---</code> and ending with <code>...</code>.
1809 </p>
1810 <pre>std.manifestYamlStream(
1811 ['a', 1, []],
1812 indent_array_in_object=false,
1813 c_document_end=true)</pre>
1814 <p>
1815 Yields this string:
1816 </p>
1817 <pre>---
1818 "a"
1819 ---
1820 1
1821 ---
1822 []
1823 ...</pre>
1824 <p>
1825 The <code>indent_array_in_object</code> and <code>quote_keys</code> params are the
1826 same as in <code>manifestYamlDoc</code>.
1827 </p>
1828 <p>
1829 The <code>c_document_end</code> param adds the optional terminating <code>...</code>.
1830 </p>
1831
1832 </div>
1833 <div style="clear: both"></div>
1834 </div>
1835 </div>
1836
1837 <div class="hgroup">
1838 <div class="hgroup-inline">
1839 <div class="panel">
1840 <h4 id="std-manifestXmlJsonml">
1841 std.manifestXmlJsonml(value)
1842 </h4>
1843 </div>
1844 <div style="clear: both"></div>
1845 </div>
1846 </div>
1847 <div class="hgroup">
1848 <div class="hgroup-inline">
1849 <div class="panel">
1850 <p>
1851 <em>
1852 Available since version 0.10.0.
1853 </em>
1854 </p>
1855 <p>
1856 Convert the given <a href="http://www.jsonml.org/">JsonML</a>-encoded value to a string
1857 containing the XML.
1858 </p>
1859 <pre>std.manifestXmlJsonml([
1860 'svg', { height: 100, width: 100 },
1861 [
1862 'circle', {
1863 cx: 50, cy: 50, r: 40,
1864 stroke: 'black', 'stroke-width': 3,
1865 fill: 'red',
1866 }
1867 ],
1868 ])</pre>
1869 <p>
1870 Yields a string containing this XML (all on one line):
1871 </p>
1872 <pre>&lt;svg height="100" width="100"&gt;
1873 &lt;circle cx="50" cy="50" fill="red" r="40"
1874 stroke="black" stroke-width="3"&gt;&lt;/circle&gt;;
1875 &lt;/svg&gt;;</pre>
1876 <p>
1877 Which represents the following image:
1878 </p>
1879 <svg height="100" width="100">
1880 <circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" />
1881 Sorry, your browser does not support inline SVG.
1882 </svg>
1883 <p>
1884 JsonML is designed to preserve "mixed-mode content" (i.e., textual data outside of or next
1885 to elements). This includes the whitespace needed to avoid having all the XML on one line,
1886 which is meaningful in XML. In order to have whitespace in the XML output, it must be
1887 present in the JsonML input:
1888 </p>
1889 <pre>std.manifestXmlJsonml([
1890 'svg',
1891 { height: 100, width: 100 },
1892 '\n ',
1893 [
1894 'circle',
1895 {
1896 cx: 50, cy: 50, r: 40, stroke: 'black',
1897 'stroke-width': 3, fill: 'red',
1898 }
1899 ],
1900 '\n',
1901 ])</pre>
1902
1903 </div>
1904 <div style="clear: both"></div>
1905 </div>
1906 </div>
1907
1908 <div class="hgroup">
1909 <div class="hgroup-inline">
1910 <div class="panel">
1911 <h4 id="std-manifestTomlEx">
1912 std.manifestTomlEx(value, indent)
1913 </h4>
1914 </div>
1915 <div style="clear: both"></div>
1916 </div>
1917 </div>
1918 <div class="hgroup">
1919 <div class="hgroup-inline">
1920 <div class="panel">
1921 <p>
1922 <em>
1923 Available since version 0.18.0.
1924 </em>
1925 </p>
1926 <p>
1927 Convert the given object to a TOML form. <code>indent</code> is a string containing
1928 one or more whitespaces that are used for indentation:
1929 </p>
1930 <p>
1931 Example:
1932 </p><pre>std.manifestTomlEx({
1933 key1: "value",
1934 key2: 1,
1935 section: {
1936 a: 1,
1937 b: "str",
1938 c: false,
1939 d: [1, "s", [2, 3]],
1940 subsection: {
1941 k: "v",
1942 },
1943 },
1944 sectionArray: [
1945 { k: "v1", v: 123 },
1946 { k: "v2", c: "value2" },
1947 ],
1948 }, " ")</pre><p>
1949 Yields a string containing this TOML file:
1950 </p><pre>key1 = "value"
1951 key2 = 1
1952
1953 [section]
1954 a = 1
1955 b = "str"
1956 c = false
1957 d = [
1958 1,
1959 "s",
1960 [ 2, 3 ]
1961 ]
1962
1963 [section.subsection]
1964 k = "v"
1965
1966 [[sectionArray]]
1967 k = "v1"
1968 v = 123
1969
1970 [[sectionArray]]
1971 c = "value2"
1972 k = "v2"</pre>
1973 </div>
1974 <div style="clear: both"></div>
1975 </div>
1976 </div>
1977
1978
1979 <div class="hgroup">
1980 <div class="hgroup-inline">
1981 <div class="panel">
1982 <h3 id="arrays">
1983 Arrays
1984 </h3>
1985 </div>
1986 <div style="clear: both"></div>
1987 </div>
1988 </div>
1989
1990 <div class="hgroup">
1991 <div class="hgroup-inline">
1992 <div class="panel">
1993 <h4 id="std-makeArray">
1994 std.makeArray(sz, func)
1995 </h4>
1996 </div>
1997 <div style="clear: both"></div>
1998 </div>
1999 </div>
2000 <div class="hgroup">
2001 <div class="hgroup-inline">
2002 <div class="panel">
2003 <p>
2004 <em>
2005 Available since version 0.10.0.
2006 </em>
2007 </p>
2008 <p>
2009 Create a new array of <code>sz</code> elements by calling <code>func(i)</code> to initialize
2010 each element. Func is expected to be a function that takes a single parameter, the index of
2011 the element it should initialize.
2012 </p>
2013 <p>
2014 Example: <code>std.makeArray(3,function(x) x * x)</code> yields <code>[ 0, 1, 4 ]</code>.
2015 </p>
2016 </div>
2017 <div style="clear: both"></div>
2018 </div>
2019 </div>
2020
2021 <div class="hgroup">
2022 <div class="hgroup-inline">
2023 <div class="panel">
2024 <h4 id="std-member">
2025 std.member(arr, x)
2026 </h4>
2027 </div>
2028 <div style="clear: both"></div>
2029 </div>
2030 </div>
2031 <div class="hgroup">
2032 <div class="hgroup-inline">
2033 <div class="panel">
2034 <p>
2035 <em>
2036 Available since version 0.15.0.
2037 </em>
2038 </p>
2039 <p>
2040 Returns whether <code>x</code> occurs in <code>arr</code>.
2041 Argument <code>arr</code> may be an array or a string.
2042 </p>
2043
2044 </div>
2045 <div style="clear: both"></div>
2046 </div>
2047 </div>
2048
2049 <div class="hgroup">
2050 <div class="hgroup-inline">
2051 <div class="panel">
2052 <h4 id="std-count">
2053 std.count(arr, x)
2054 </h4>
2055 </div>
2056 <div style="clear: both"></div>
2057 </div>
2058 </div>
2059 <div class="hgroup">
2060 <div class="hgroup-inline">
2061 <div class="panel">
2062 <p>
2063 <em>
2064 Available since version 0.10.0.
2065 </em>
2066 </p>
2067 <p>
2068 Return the number of times that <code>x</code> occurs in <code>arr</code>.
2069 </p>
2070
2071 </div>
2072 <div style="clear: both"></div>
2073 </div>
2074 </div>
2075
2076 <div class="hgroup">
2077 <div class="hgroup-inline">
2078 <div class="panel">
2079 <h4 id="std-find">
2080 std.find(value, arr)
2081 </h4>
2082 </div>
2083 <div style="clear: both"></div>
2084 </div>
2085 </div>
2086 <div class="hgroup">
2087 <div class="hgroup-inline">
2088 <div class="panel">
2089 <p>
2090 <em>
2091 Available since version 0.10.0.
2092 </em>
2093 </p>
2094 <p>
2095 Returns an array that contains the indexes of all occurrences of <code>value</code> in
2096 <code>arr</code>.
2097 </p>
2098
2099 </div>
2100 <div style="clear: both"></div>
2101 </div>
2102 </div>
2103
2104 <div class="hgroup">
2105 <div class="hgroup-inline">
2106 <div class="panel">
2107 <h4 id="std-map">
2108 std.map(func, arr)
2109 </h4>
2110 </div>
2111 <div style="clear: both"></div>
2112 </div>
2113 </div>
2114 <div class="hgroup">
2115 <div class="hgroup-inline">
2116 <div class="panel">
2117 <p>
2118 <em>
2119 Available since version 0.10.0.
2120 </em>
2121 </p>
2122 <p>
2123 Apply the given function to every element of the array to form a new array.
2124 </p>
2125
2126 </div>
2127 <div style="clear: both"></div>
2128 </div>
2129 </div>
2130
2131 <div class="hgroup">
2132 <div class="hgroup-inline">
2133 <div class="panel">
2134 <h4 id="std-mapWithIndex">
2135 std.mapWithIndex(func, arr)
2136 </h4>
2137 </div>
2138 <div style="clear: both"></div>
2139 </div>
2140 </div>
2141 <div class="hgroup">
2142 <div class="hgroup-inline">
2143 <div class="panel">
2144 <p>
2145 <em>
2146 Available since version 0.10.0.
2147 </em>
2148 </p>
2149 <p>
2150 Similar to <a href="#map">map</a> above, but it also passes to the function the element's
2151 index in the array. The function <code>func</code> is expected to take the index as the
2152 first parameter and the element as the second.
2153 </p>
2154
2155 </div>
2156 <div style="clear: both"></div>
2157 </div>
2158 </div>
2159
2160 <div class="hgroup">
2161 <div class="hgroup-inline">
2162 <div class="panel">
2163 <h4 id="std-filterMap">
2164 std.filterMap(filter_func, map_func, arr)
2165 </h4>
2166 </div>
2167 <div style="clear: both"></div>
2168 </div>
2169 </div>
2170 <div class="hgroup">
2171 <div class="hgroup-inline">
2172 <div class="panel">
2173 <p>
2174 <em>
2175 Available since version 0.10.0.
2176 </em>
2177 </p>
2178 <p>
2179 It first filters, then maps the given array, using the two functions provided.
2180 </p>
2181
2182 </div>
2183 <div style="clear: both"></div>
2184 </div>
2185 </div>
2186
2187 <div class="hgroup">
2188 <div class="hgroup-inline">
2189 <div class="panel">
2190 <h4 id="std-flatMap">
2191 std.flatMap(func, arr)
2192 </h4>
2193 </div>
2194 <div style="clear: both"></div>
2195 </div>
2196 </div>
2197 <div class="hgroup">
2198 <div class="hgroup-inline">
2199 <div class="panel">
2200 <p>
2201 <em>
2202 Available since version 0.10.0.
2203 </em>
2204 </p>
2205 <p>
2206 Apply the given function to every element of <code>arr</code> to form a new array then flatten the result.
2207 The argument <code>arr</code> must be an array or a string. If <code>arr</code> is an array, function <code>func</code> must return an array.
2208 If <code>arr</code> is a string, function <code>func</code> must return an string.
2209 </p>
2210 <p>
2211 The <code>std.flatMap</code> function can be thought of as a generalized <code>std.map</code>,
2212 with each element mapped to 0, 1 or more elements.
2213 </p>
2214 <p>
2215 Example: <code>std.flatMap(function(x) [x, x], [1, 2, 3])</code> yields <code>[ 1, 1, 2, 2, 3, 3 ]</code>.
2216 </p>
2217 <p>
2218 Example: <code>std.flatMap(function(x) if x == 2 then [] else [x], [1, 2, 3])</code> yields <code>[ 1, 3 ]</code>.
2219 </p>
2220 <p>
2221 Example: <code>std.flatMap(function(x) if x == 2 then [] else [x * 3, x * 2], [1, 2, 3])</code> yields <code>[ 3, 2, 9, 6 ]</code>.
2222 </p>
2223 <p>
2224 Example: <code>std.flatMap(function(x) x+x, "foo")</code> yields <code>"ffoooo"</code>.
2225 </p>
2226 </div>
2227 <div style="clear: both"></div>
2228 </div>
2229 </div>
2230
2231 <div class="hgroup">
2232 <div class="hgroup-inline">
2233 <div class="panel">
2234 <h4 id="std-filter">
2235 std.filter(func, arr)
2236 </h4>
2237 </div>
2238 <div style="clear: both"></div>
2239 </div>
2240 </div>
2241 <div class="hgroup">
2242 <div class="hgroup-inline">
2243 <div class="panel">
2244 <p>
2245 <em>
2246 Available since version 0.10.0.
2247 </em>
2248 </p>
2249 <p>
2250 Return a new array containing all the elements of <code>arr</code> for which the
2251 <code>func</code> function returns true.
2252 </p>
2253
2254 </div>
2255 <div style="clear: both"></div>
2256 </div>
2257 </div>
2258
2259 <div class="hgroup">
2260 <div class="hgroup-inline">
2261 <div class="panel">
2262 <h4 id="std-foldl">
2263 std.foldl(func, arr, init)
2264 </h4>
2265 </div>
2266 <div style="clear: both"></div>
2267 </div>
2268 </div>
2269 <div class="hgroup">
2270 <div class="hgroup-inline">
2271 <div class="panel">
2272 <p>
2273 <em>
2274 Available since version 0.10.0.
2275 </em>
2276 </p>
2277 <p>
2278 Classic foldl function. Calls the function for each array element, passing the result from
2279 the previous call (or <code>init</code> for the first call), and the array element. Traverses
2280 the array from left to right.
2281 </p>
2282 <p>
2283 For example: <code>foldl(f, [1,2,3], 0)</code> is equivalent to <code>f(f(f(0, 1), 2), 3)</code>.
2284 </p>
2285
2286 </div>
2287 <div style="clear: both"></div>
2288 </div>
2289 </div>
2290
2291 <div class="hgroup">
2292 <div class="hgroup-inline">
2293 <div class="panel">
2294 <h4 id="std-foldr">
2295 std.foldr(func, arr, init)
2296 </h4>
2297 </div>
2298 <div style="clear: both"></div>
2299 </div>
2300 </div>
2301 <div class="hgroup">
2302 <div class="hgroup-inline">
2303 <div class="panel">
2304 <p>
2305 <em>
2306 Available since version 0.10.0.
2307 </em>
2308 </p>
2309 <p>
2310 Classic foldr function. Calls the function for each array element, passing the array element
2311 and the result from the previous call (or <code>init</code> for the first call). Traverses
2312 the array from right to left.
2313 </p>
2314 <p>
2315 For example: <code>foldr(f, [1,2,3], 0)</code> is equivalent to <code>f(1, f(2, f(3, 0)))</code>.
2316 </p>
2317
2318 </div>
2319 <div style="clear: both"></div>
2320 </div>
2321 </div>
2322
2323 <div class="hgroup">
2324 <div class="hgroup-inline">
2325 <div class="panel">
2326 <h4 id="std-range">
2327 std.range(from, to)
2328 </h4>
2329 </div>
2330 <div style="clear: both"></div>
2331 </div>
2332 </div>
2333 <div class="hgroup">
2334 <div class="hgroup-inline">
2335 <div class="panel">
2336 <p>
2337 <em>
2338 Available since version 0.10.0.
2339 </em>
2340 </p>
2341 <p>
2342 Return an array of ascending numbers between the two limits, inclusively.
2343 </p>
2344
2345 </div>
2346 <div style="clear: both"></div>
2347 </div>
2348 </div>
2349
2350 <div class="hgroup">
2351 <div class="hgroup-inline">
2352 <div class="panel">
2353 <h4 id="std-repeat">
2354 std.repeat(what, count)
2355 </h4>
2356 </div>
2357 <div style="clear: both"></div>
2358 </div>
2359 </div>
2360 <div class="hgroup">
2361 <div class="hgroup-inline">
2362 <div class="panel">
2363 <p>
2364 <em>
2365 Available since version 0.15.0.
2366 </em>
2367 </p>
2368 <p>
2369 Repeats an array or a string <code>what</code> a number of times specified by an integer <code>count</code>.
2370 </p>
2371 <p>
2372 Example: <code>std.repeat([1, 2, 3], 3)</code> yields <code>[ 1, 2, 3, 1, 2, 3, 1, 2, 3 ]</code>.
2373 </p>
2374 <p>
2375 Example: <code>std.repeat("blah", 2)</code> yields <code>"blahblah"</code>.
2376 </p>
2377 </div>
2378 <div style="clear: both"></div>
2379 </div>
2380 </div>
2381
2382 <div class="hgroup">
2383 <div class="hgroup-inline">
2384 <div class="panel">
2385 <h4 id="std-slice">
2386 std.slice(indexable, index, end, step)
2387 </h4>
2388 </div>
2389 <div style="clear: both"></div>
2390 </div>
2391 </div>
2392 <div class="hgroup">
2393 <div class="hgroup-inline">
2394 <div class="panel">
2395 <p>
2396 <em>
2397 Available since version 0.10.0.
2398 </em>
2399 </p>
2400 <p>
2401 Selects the elements of an array or a string from <code>index</code> to <code>end</code> with <code>step</code> and returns an array or a string respectively.
2402 </p>
2403 <p>
2404 Note that it's recommended to use dedicated slicing syntax both for arrays and strings (e.g. <code>arr[0:4:1]</code> instead of <code>std.slice(arr, 0, 4, 1)</code>).
2405 </p>
2406 <p>
2407 Example: <code>std.slice([1, 2, 3, 4, 5, 6], 0, 4, 1)</code> yields <code>[ 1, 2, 3, 4 ]</code>.
2408 </p>
2409 <p>
2410 Example: <code>std.slice([1, 2, 3, 4, 5, 6], 1, 6, 2)</code> yields <code>[ 2, 4, 6 ]</code>.
2411 </p>
2412 <p>
2413 Example: <code>std.slice("jsonnet", 0, 4, 1)</code> yields <code>"json"</code>.
2414 </p>
2415 <p>
2416 Example: <code>std.slice("jsonnet", -3, null, null)</code> yields <code>"net"</code>.
2417 </p>
2418 </div>
2419 <div style="clear: both"></div>
2420 </div>
2421 </div>
2422
2423 <div class="hgroup">
2424 <div class="hgroup-inline">
2425 <div class="panel">
2426 <h4 id="std-join">
2427 std.join(sep, arr)
2428 </h4>
2429 </div>
2430 <div style="clear: both"></div>
2431 </div>
2432 </div>
2433 <div class="hgroup">
2434 <div class="hgroup-inline">
2435 <div class="panel">
2436 <p>
2437 <em>
2438 Available since version 0.10.0.
2439 </em>
2440 </p>
2441 <p>
2442 If <code>sep</code> is a string, then <code>arr</code> must be an array of strings, in which
2443 case they are concatenated with <code>sep</code> used as a delimiter. If <code>sep</code>
2444 is an array, then <code>arr</code> must be an array of arrays, in which case the arrays are
2445 concatenated in the same way, to produce a single array.
2446 </p>
2447 <p>
2448 Example: <code>std.join(".", ["www", "google", "com"])</code> yields <code>"www.google.com"</code>.
2449 </p>
2450 <p>
2451 Example: <code>std.join([9, 9], [[1], [2, 3]])</code> yields <code>[ 1, 9, 9, 2, 3 ]</code>.
2452 </p>
2453 </div>
2454 <div style="clear: both"></div>
2455 </div>
2456 </div>
2457
2458 <div class="hgroup">
2459 <div class="hgroup-inline">
2460 <div class="panel">
2461 <h4 id="std-deepJoin">
2462 std.deepJoin(arr)
2463 </h4>
2464 </div>
2465 <div style="clear: both"></div>
2466 </div>
2467 </div>
2468 <div class="hgroup">
2469 <div class="hgroup-inline">
2470 <div class="panel">
2471 <p>
2472 <em>
2473 Available since version 0.10.0.
2474 </em>
2475 </p>
2476 <p>
2477 Concatenate an array containing strings and arrays to form a single string. If <code>arr</code> is
2478 a string, it is returned unchanged. If it is an array, it is flattened and the string elements are
2479 concatenated together with no separator.
2480 </p>
2481 <p>
2482 Example: <code>std.deepJoin(["one ", ["two ", "three ", ["four "], []], "five ", ["six"]])</code> yields <code>"one two three four five six"</code>.
2483 </p>
2484 <p>
2485 Example: <code>std.deepJoin("hello")</code> yields <code>"hello"</code>.
2486 </p>
2487 </div>
2488 <div style="clear: both"></div>
2489 </div>
2490 </div>
2491
2492 <div class="hgroup">
2493 <div class="hgroup-inline">
2494 <div class="panel">
2495 <h4 id="std-lines">
2496 std.lines(arr)
2497 </h4>
2498 </div>
2499 <div style="clear: both"></div>
2500 </div>
2501 </div>
2502 <div class="hgroup">
2503 <div class="hgroup-inline">
2504 <div class="panel">
2505 <p>
2506 <em>
2507 Available since version 0.10.0.
2508 </em>
2509 </p>
2510 <p>
2511 Concatenate an array of strings into a text file with newline characters after each string.
2512 This is suitable for constructing bash scripts and the like.
2513 </p>
2514
2515 </div>
2516 <div style="clear: both"></div>
2517 </div>
2518 </div>
2519
2520 <div class="hgroup">
2521 <div class="hgroup-inline">
2522 <div class="panel">
2523 <h4 id="std-flattenArrays">
2524 std.flattenArrays(arr)
2525 </h4>
2526 </div>
2527 <div style="clear: both"></div>
2528 </div>
2529 </div>
2530 <div class="hgroup">
2531 <div class="hgroup-inline">
2532 <div class="panel">
2533 <p>
2534 <em>
2535 Available since version 0.10.0.
2536 </em>
2537 </p>
2538 <p>
2539 Concatenate an array of arrays into a single array.
2540 </p>
2541 <p>
2542 Example: <code>std.flattenArrays([[1, 2], [3, 4], [[5, 6], [7, 8]]])</code> yields <code>[ 1, 2, 3, 4, [ 5, 6 ], [ 7, 8 ] ]</code>.
2543 </p>
2544 </div>
2545 <div style="clear: both"></div>
2546 </div>
2547 </div>
2548
2549 <div class="hgroup">
2550 <div class="hgroup-inline">
2551 <div class="panel">
2552 <h4 id="std-flattenDeepArray">
2553 std.flattenDeepArray(value)
2554 </h4>
2555 </div>
2556 <div style="clear: both"></div>
2557 </div>
2558 </div>
2559 <div class="hgroup">
2560 <div class="hgroup-inline">
2561 <div class="panel">
2562 <p>
2563 <em>
2564 Available since version 0.21.0.
2565 </em>
2566 </p>
2567 <p>
2568 Concatenate an array containing values and arrays into a single flattened array.
2569 </p>
2570 <p>
2571 Example: <code>std.flattenDeepArray([[1, 2], [], [3, [4]], [[5, 6, [null]], [7, 8]]])</code> yields <code>[ 1, 2, 3, 4, 5, 6, null, 7, 8 ]</code>.
2572 </p>
2573 </div>
2574 <div style="clear: both"></div>
2575 </div>
2576 </div>
2577
2578 <div class="hgroup">
2579 <div class="hgroup-inline">
2580 <div class="panel">
2581 <h4 id="std-reverse">
2582 std.reverse(arrs)
2583 </h4>
2584 </div>
2585 <div style="clear: both"></div>
2586 </div>
2587 </div>
2588 <div class="hgroup">
2589 <div class="hgroup-inline">
2590 <div class="panel">
2591 <p>
2592 <em>
2593 Available since version 0.13.0.
2594 </em>
2595 </p>
2596 <p>
2597 Reverses an array.
2598 </p>
2599
2600 </div>
2601 <div style="clear: both"></div>
2602 </div>
2603 </div>
2604
2605 <div class="hgroup">
2606 <div class="hgroup-inline">
2607 <div class="panel">
2608 <h4 id="std-sort">
2609 std.sort(arr, keyF=id)
2610 </h4>
2611 </div>
2612 <div style="clear: both"></div>
2613 </div>
2614 </div>
2615 <div class="hgroup">
2616 <div class="hgroup-inline">
2617 <div class="panel">
2618 <p>
2619 <em>
2620 Available since version 0.10.0.
2621 </em>
2622 </p>
2623 <p>
2624 Sorts the array using the <= operator.
2625 </p>
2626 <p>
2627 Optional argument <code>keyF</code> is a single argument function used to extract comparison key from each array element.
2628 Default value is identity function <code>keyF=function(x) x</code>.
2629 </p>
2630
2631 </div>
2632 <div style="clear: both"></div>
2633 </div>
2634 </div>
2635
2636 <div class="hgroup">
2637 <div class="hgroup-inline">
2638 <div class="panel">
2639 <h4 id="std-uniq">
2640 std.uniq(arr, keyF=id)
2641 </h4>
2642 </div>
2643 <div style="clear: both"></div>
2644 </div>
2645 </div>
2646 <div class="hgroup">
2647 <div class="hgroup-inline">
2648 <div class="panel">
2649 <p>
2650 <em>
2651 Available since version 0.10.0.
2652 </em>
2653 </p>
2654 <p>
2655 Removes successive duplicates. When given a sorted array, removes all duplicates.
2656 </p>
2657 <p>
2658 Optional argument <code>keyF</code> is a single argument function used to extract comparison key from each array element.
2659 Default value is identity function <code>keyF=function(x) x</code>.
2660 </p>
2661
2662 </div>
2663 <div style="clear: both"></div>
2664 </div>
2665 </div>
2666
2667 <div class="hgroup">
2668 <div class="hgroup-inline">
2669 <div class="panel">
2670 <h4 id="std-all">
2671 std.all(arr)
2672 </h4>
2673 </div>
2674 <div style="clear: both"></div>
2675 </div>
2676 </div>
2677 <div class="hgroup">
2678 <div class="hgroup-inline">
2679 <div class="panel">
2680 <p>
2681 <em>
2682 Available since version 0.19.0.
2683 </em>
2684 </p>
2685 <p>
2686 Return true if all elements of <code>arr</code> is true, false otherwise. <code>all([])</code> evaluates to true.
2687 </p>
2688 <p>
2689 It's an error if 1) <code>arr</code> is not an array, or 2) <code>arr</code> contains non-boolean values.
2690 </p>
2691
2692 </div>
2693 <div style="clear: both"></div>
2694 </div>
2695 </div>
2696
2697 <div class="hgroup">
2698 <div class="hgroup-inline">
2699 <div class="panel">
2700 <h4 id="std-any">
2701 std.any(arr)
2702 </h4>
2703 </div>
2704 <div style="clear: both"></div>
2705 </div>
2706 </div>
2707 <div class="hgroup">
2708 <div class="hgroup-inline">
2709 <div class="panel">
2710 <p>
2711 <em>
2712 Available since version 0.19.0.
2713 </em>
2714 </p>
2715 <p>
2716 Return true if any element of <code>arr</code> is true, false otherwise. <code>any([])</code> evaluates to false.
2717 </p>
2718 <p>
2719 It's an error if 1) <code>arr</code> is not an array, or 2) <code>arr</code> contains non-boolean values.
2720 </p>
2721
2722 </div>
2723 <div style="clear: both"></div>
2724 </div>
2725 </div>
2726
2727 <div class="hgroup">
2728 <div class="hgroup-inline">
2729 <div class="panel">
2730 <h4 id="std-sum">
2731 std.sum(arr)
2732 </h4>
2733 </div>
2734 <div style="clear: both"></div>
2735 </div>
2736 </div>
2737 <div class="hgroup">
2738 <div class="hgroup-inline">
2739 <div class="panel">
2740 <p>
2741 <em>
2742 Available since version 0.20.0.
2743 </em>
2744 </p>
2745 <p>
2746 Return sum of all element in <code>arr</code>.
2747 </p>
2748
2749 </div>
2750 <div style="clear: both"></div>
2751 </div>
2752 </div>
2753
2754 <div class="hgroup">
2755 <div class="hgroup-inline">
2756 <div class="panel">
2757 <h4 id="std-minArray">
2758 std.minArray(arr, keyF, onEmpty)
2759 </h4>
2760 </div>
2761 <div style="clear: both"></div>
2762 </div>
2763 </div>
2764 <div class="hgroup">
2765 <div class="hgroup-inline">
2766 <div class="panel">
2767 <p>
2768 <em>
2769 Available since version 0.21.0.
2770 </em>
2771 </p>
2772 <p>
2773 Return the minimum of all elements in <code>arr</code>. If <code>keyF</code> is provided, it is called on each element
2774 of the array and should return a comparator value, and in this case <code>minArray</code> will return an element
2775 with the minimum comparator value. If <code>onEmpty</code> is provided, and <code>arr</code> is empty, then
2776 <code>minArray</code> will return the provided <code>onEmpty</code> value. If <code>onEmpty</code> is not provided,
2777 then an empty <code>arr</code> will raise an error.
2778 </p>
2779
2780 </div>
2781 <div style="clear: both"></div>
2782 </div>
2783 </div>
2784
2785 <div class="hgroup">
2786 <div class="hgroup-inline">
2787 <div class="panel">
2788 <h4 id="std-maxArray">
2789 std.maxArray(arr, keyF, onEmpty)
2790 </h4>
2791 </div>
2792 <div style="clear: both"></div>
2793 </div>
2794 </div>
2795 <div class="hgroup">
2796 <div class="hgroup-inline">
2797 <div class="panel">
2798 <p>
2799 <em>
2800 Available since version 0.21.0.
2801 </em>
2802 </p>
2803 <p>
2804 Return the maximum of all elements in <code>arr</code>. If <code>keyF</code> is provided, it is called on each element
2805 of the array and should return a comparator value, and in this case <code>maxArray</code> will return an element
2806 with the maximum comparator value. If <code>onEmpty</code> is provided, and <code>arr</code> is empty, then
2807 <code>maxArray</code> will return the provided <code>onEmpty</code> value. If <code>onEmpty</code> is not provided,
2808 then an empty <code>arr</code> will raise an error.
2809 </p>
2810
2811 </div>
2812 <div style="clear: both"></div>
2813 </div>
2814 </div>
2815
2816 <div class="hgroup">
2817 <div class="hgroup-inline">
2818 <div class="panel">
2819 <h4 id="std-contains">
2820 std.contains(arr, elem)
2821 </h4>
2822 </div>
2823 <div style="clear: both"></div>
2824 </div>
2825 </div>
2826 <div class="hgroup">
2827 <div class="hgroup-inline">
2828 <div class="panel">
2829 <p>
2830 <em>
2831 Available since version 0.21.0.
2832 </em>
2833 </p>
2834 <p>
2835 Return true if given <code>elem</code> is present in <code>arr</code>, false otherwise.
2836 </p>
2837
2838 </div>
2839 <div style="clear: both"></div>
2840 </div>
2841 </div>
2842
2843 <div class="hgroup">
2844 <div class="hgroup-inline">
2845 <div class="panel">
2846 <h4 id="std-avg">
2847 std.avg(arr)
2848 </h4>
2849 </div>
2850 <div style="clear: both"></div>
2851 </div>
2852 </div>
2853 <div class="hgroup">
2854 <div class="hgroup-inline">
2855 <div class="panel">
2856 <p>
2857 <em>
2858 Available since version 0.21.0.
2859 </em>
2860 </p>
2861 <p>
2862 Return average of all element in <code>arr</code>.
2863 </p>
2864
2865 </div>
2866 <div style="clear: both"></div>
2867 </div>
2868 </div>
2869
2870 <div class="hgroup">
2871 <div class="hgroup-inline">
2872 <div class="panel">
2873 <h4 id="std-remove">
2874 std.remove(arr, elem)
2875 </h4>
2876 </div>
2877 <div style="clear: both"></div>
2878 </div>
2879 </div>
2880 <div class="hgroup">
2881 <div class="hgroup-inline">
2882 <div class="panel">
2883 <p>
2884 <em>
2885 Available since version 0.21.0.
2886 </em>
2887 </p>
2888 <p>
2889 Remove first occurrence of <code>elem</code> from <code>arr</code>.
2890 </p>
2891
2892 </div>
2893 <div style="clear: both"></div>
2894 </div>
2895 </div>
2896
2897 <div class="hgroup">
2898 <div class="hgroup-inline">
2899 <div class="panel">
2900 <h4 id="std-removeAt">
2901 std.removeAt(arr, idx)
2902 </h4>
2903 </div>
2904 <div style="clear: both"></div>
2905 </div>
2906 </div>
2907 <div class="hgroup">
2908 <div class="hgroup-inline">
2909 <div class="panel">
2910 <p>
2911 <em>
2912 Available since version 0.21.0.
2913 </em>
2914 </p>
2915 <p>
2916 Remove element at <code>idx</code> index from <code>arr</code>.
2917 </p>
2918
2919 </div>
2920 <div style="clear: both"></div>
2921 </div>
2922 </div>
2923
2924
2925 <div class="hgroup">
2926 <div class="hgroup-inline">
2927 <div class="panel">
2928 <h3 id="sets">
2929 Sets
2930 </h3>
2931 </div>
2932 <div style="clear: both"></div>
2933 </div>
2934 </div>
2935 <div class="hgroup">
2936 <div class="hgroup-inline">
2937 <div class="panel">
2938 <p>
2939 Sets are represented as ordered arrays without duplicates.
2940 </p>
2941 <p>
2942 Note that the <code>std.set*</code> functions rely on the uniqueness and ordering
2943 on arrays passed to them to work. This can be guaranteed by using <code>std.set(arr)</code>.
2944 If that is not the case, the functions will quietly return non-meaningful results.
2945 </p>
2946 <p>
2947 All <code>set.set*</code> functions accept <code>keyF</code> function of one argument, which can be
2948 used to extract key to use from each element. All Set operations then use extracted key for the purpose
2949 of identifying uniqueness. Default value is identity function <code>local id = function(x) x</code>.
2950 </p>
2951 </div>
2952 <div style="clear: both"></div>
2953 </div>
2954 </div>
2955
2956 <div class="hgroup">
2957 <div class="hgroup-inline">
2958 <div class="panel">
2959 <h4 id="std-set">
2960 std.set(arr, keyF=id)
2961 </h4>
2962 </div>
2963 <div style="clear: both"></div>
2964 </div>
2965 </div>
2966 <div class="hgroup">
2967 <div class="hgroup-inline">
2968 <div class="panel">
2969 <p>
2970 <em>
2971 Available since version 0.10.0.
2972 </em>
2973 </p>
2974 <p>
2975 Shortcut for std.uniq(std.sort(arr)).
2976 </p>
2977
2978 </div>
2979 <div style="clear: both"></div>
2980 </div>
2981 </div>
2982
2983 <div class="hgroup">
2984 <div class="hgroup-inline">
2985 <div class="panel">
2986 <h4 id="std-setInter">
2987 std.setInter(a, b, keyF=id)
2988 </h4>
2989 </div>
2990 <div style="clear: both"></div>
2991 </div>
2992 </div>
2993 <div class="hgroup">
2994 <div class="hgroup-inline">
2995 <div class="panel">
2996 <p>
2997 <em>
2998 Available since version 0.10.0.
2999 </em>
3000 </p>
3001 <p>
3002 Set intersection operation (values in both a and b).
3003 </p>
3004
3005 </div>
3006 <div style="clear: both"></div>
3007 </div>
3008 </div>
3009
3010 <div class="hgroup">
3011 <div class="hgroup-inline">
3012 <div class="panel">
3013 <h4 id="std-setUnion">
3014 std.setUnion(a, b, keyF=id)
3015 </h4>
3016 </div>
3017 <div style="clear: both"></div>
3018 </div>
3019 </div>
3020 <div class="hgroup">
3021 <div class="hgroup-inline">
3022 <div class="panel">
3023 <p>
3024 <em>
3025 Available since version 0.10.0.
3026 </em>
3027 </p>
3028 <p>
3029 Set union operation (values in any of <code>a</code> or <code>b</code>). Note that + on sets will simply
3030 concatenate
3031 the arrays, possibly forming an array that is not a set (due to not being ordered without
3032 duplicates).
3033 </p>
3034 <p>
3035 Example: <code>std.setUnion([1, 2], [2, 3])</code> yields <code>[ 1, 2, 3 ]</code>.
3036 </p>
3037 <p>
3038 Example: <code>std.setUnion([{n:"A", v:1}, {n:"B"}], [{n:"A", v: 9999}, {n:"C"}], keyF=function(x) x.n)</code> yields <code>[ { "n": "A", "v": 1 }, { "n": "B" }, { "n": "C" } ]</code>.
3039 </p>
3040 </div>
3041 <div style="clear: both"></div>
3042 </div>
3043 </div>
3044
3045 <div class="hgroup">
3046 <div class="hgroup-inline">
3047 <div class="panel">
3048 <h4 id="std-setDiff">
3049 std.setDiff(a, b, keyF=id)
3050 </h4>
3051 </div>
3052 <div style="clear: both"></div>
3053 </div>
3054 </div>
3055 <div class="hgroup">
3056 <div class="hgroup-inline">
3057 <div class="panel">
3058 <p>
3059 <em>
3060 Available since version 0.10.0.
3061 </em>
3062 </p>
3063 <p>
3064 Set difference operation (values in a but not b).
3065 </p>
3066
3067 </div>
3068 <div style="clear: both"></div>
3069 </div>
3070 </div>
3071
3072 <div class="hgroup">
3073 <div class="hgroup-inline">
3074 <div class="panel">
3075 <h4 id="std-setMember">
3076 std.setMember(x, arr, keyF=id)
3077 </h4>
3078 </div>
3079 <div style="clear: both"></div>
3080 </div>
3081 </div>
3082 <div class="hgroup">
3083 <div class="hgroup-inline">
3084 <div class="panel">
3085 <p>
3086 <em>
3087 Available since version 0.10.0.
3088 </em>
3089 </p>
3090 <p>
3091 Returns <code>true</code> if x is a member of array, otherwise <code>false</code>.
3092 </p>
3093
3094 </div>
3095 <div style="clear: both"></div>
3096 </div>
3097 </div>
3098
3099
3100 <div class="hgroup">
3101 <div class="hgroup-inline">
3102 <div class="panel">
3103 <h3 id="objects">
3104 Objects
3105 </h3>
3106 </div>
3107 <div style="clear: both"></div>
3108 </div>
3109 </div>
3110
3111 <div class="hgroup">
3112 <div class="hgroup-inline">
3113 <div class="panel">
3114 <h4 id="std-get">
3115 std.get(o, f, default=null, inc_hidden=true)
3116 </h4>
3117 </div>
3118 <div style="clear: both"></div>
3119 </div>
3120 </div>
3121 <div class="hgroup">
3122 <div class="hgroup-inline">
3123 <div class="panel">
3124 <p>
3125 <em>
3126 Available since version 0.18.0.
3127 </em>
3128 </p>
3129 <p>
3130 Returns the object's field if it exists or default value otherwise.
3131 <code>inc_hidden</code> controls whether to include hidden fields.
3132 </p>
3133
3134 </div>
3135 <div style="clear: both"></div>
3136 </div>
3137 </div>
3138
3139 <div class="hgroup">
3140 <div class="hgroup-inline">
3141 <div class="panel">
3142 <h4 id="std-objectHas">
3143 std.objectHas(o, f)
3144 </h4>
3145 </div>
3146 <div style="clear: both"></div>
3147 </div>
3148 </div>
3149 <div class="hgroup">
3150 <div class="hgroup-inline">
3151 <div class="panel">
3152 <p>
3153 <em>
3154 Available since version 0.10.0.
3155 </em>
3156 </p>
3157 <p>
3158 Returns <code>true</code> if the given object has the field (given as a string), otherwise
3159 <code>false</code>. Raises an error if the arguments are not object and string
3160 respectively. Returns false if the field is hidden.
3161 </p>
3162
3163 </div>
3164 <div style="clear: both"></div>
3165 </div>
3166 </div>
3167
3168 <div class="hgroup">
3169 <div class="hgroup-inline">
3170 <div class="panel">
3171 <h4 id="std-objectFields">
3172 std.objectFields(o)
3173 </h4>
3174 </div>
3175 <div style="clear: both"></div>
3176 </div>
3177 </div>
3178 <div class="hgroup">
3179 <div class="hgroup-inline">
3180 <div class="panel">
3181 <p>
3182 <em>
3183 Available since version 0.10.0.
3184 </em>
3185 </p>
3186 <p>
3187 Returns an array of strings, each element being a field from the given object. Does not include
3188 hidden fields.
3189 </p>
3190
3191 </div>
3192 <div style="clear: both"></div>
3193 </div>
3194 </div>
3195
3196 <div class="hgroup">
3197 <div class="hgroup-inline">
3198 <div class="panel">
3199 <h4 id="std-objectValues">
3200 std.objectValues(o)
3201 </h4>
3202 </div>
3203 <div style="clear: both"></div>
3204 </div>
3205 </div>
3206 <div class="hgroup">
3207 <div class="hgroup-inline">
3208 <div class="panel">
3209 <p>
3210 <em>
3211 Available since version 0.17.0.
3212 </em>
3213 </p>
3214 <p>
3215 Returns an array of the values in the given object. Does not include hidden fields.
3216 </p>
3217
3218 </div>
3219 <div style="clear: both"></div>
3220 </div>
3221 </div>
3222
3223 <div class="hgroup">
3224 <div class="hgroup-inline">
3225 <div class="panel">
3226 <h4 id="std-objectKeysValues">
3227 std.objectKeysValues(o)
3228 </h4>
3229 </div>
3230 <div style="clear: both"></div>
3231 </div>
3232 </div>
3233 <div class="hgroup">
3234 <div class="hgroup-inline">
3235 <div class="panel">
3236 <p>
3237 <em>
3238 Available since version 0.20.0.
3239 </em>
3240 </p>
3241 <p>
3242 Returns an array of objects from the given object, each object having two fields:
3243 <code>key</code> (string) and <code>value</code> (object). Does not include hidden fields.
3244 </p>
3245
3246 </div>
3247 <div style="clear: both"></div>
3248 </div>
3249 </div>
3250
3251 <div class="hgroup">
3252 <div class="hgroup-inline">
3253 <div class="panel">
3254 <h4 id="std-objectHasAll">
3255 std.objectHasAll(o, f)
3256 </h4>
3257 </div>
3258 <div style="clear: both"></div>
3259 </div>
3260 </div>
3261 <div class="hgroup">
3262 <div class="hgroup-inline">
3263 <div class="panel">
3264 <p>
3265 <em>
3266 Available since version 0.10.0.
3267 </em>
3268 </p>
3269 <p>
3270 As <code>std.objectHas</code> but also includes hidden fields.
3271 </p>
3272
3273 </div>
3274 <div style="clear: both"></div>
3275 </div>
3276 </div>
3277
3278 <div class="hgroup">
3279 <div class="hgroup-inline">
3280 <div class="panel">
3281 <h4 id="std-objectFieldsAll">
3282 std.objectFieldsAll(o)
3283 </h4>
3284 </div>
3285 <div style="clear: both"></div>
3286 </div>
3287 </div>
3288 <div class="hgroup">
3289 <div class="hgroup-inline">
3290 <div class="panel">
3291 <p>
3292 <em>
3293 Available since version 0.10.0.
3294 </em>
3295 </p>
3296 <p>
3297 As <code>std.objectFields</code> but also includes hidden fields.
3298 </p>
3299
3300 </div>
3301 <div style="clear: both"></div>
3302 </div>
3303 </div>
3304
3305 <div class="hgroup">
3306 <div class="hgroup-inline">
3307 <div class="panel">
3308 <h4 id="std-objectValuesAll">
3309 std.objectValuesAll(o)
3310 </h4>
3311 </div>
3312 <div style="clear: both"></div>
3313 </div>
3314 </div>
3315 <div class="hgroup">
3316 <div class="hgroup-inline">
3317 <div class="panel">
3318 <p>
3319 <em>
3320 Available since version 0.17.0.
3321 </em>
3322 </p>
3323 <p>
3324 As <code>std.objectValues</code> but also includes hidden fields.
3325 </p>
3326
3327 </div>
3328 <div style="clear: both"></div>
3329 </div>
3330 </div>
3331
3332 <div class="hgroup">
3333 <div class="hgroup-inline">
3334 <div class="panel">
3335 <h4 id="std-objectKeysValuesAll">
3336 std.objectKeysValuesAll(o)
3337 </h4>
3338 </div>
3339 <div style="clear: both"></div>
3340 </div>
3341 </div>
3342 <div class="hgroup">
3343 <div class="hgroup-inline">
3344 <div class="panel">
3345 <p>
3346 <em>
3347 Available since version 0.20.0.
3348 </em>
3349 </p>
3350 <p>
3351 As <code>std.objectKeysValues</code> but also includes hidden fields.
3352 </p>
3353
3354 </div>
3355 <div style="clear: both"></div>
3356 </div>
3357 </div>
3358
3359 <div class="hgroup">
3360 <div class="hgroup-inline">
3361 <div class="panel">
3362 <h4 id="std-objectRemoveKey">
3363 std.objectRemoveKey(obj, key)
3364 </h4>
3365 </div>
3366 <div style="clear: both"></div>
3367 </div>
3368 </div>
3369 <div class="hgroup">
3370 <div class="hgroup-inline">
3371 <div class="panel">
3372 <p>
3373 <em>
3374 Available since version 0.21.0.
3375 </em>
3376 </p>
3377 <p>
3378 Returns a new object after removing the given key from object.
3379 </p>
3380
3381 </div>
3382 <div style="clear: both"></div>
3383 </div>
3384 </div>
3385
3386 <div class="hgroup">
3387 <div class="hgroup-inline">
3388 <div class="panel">
3389 <h4 id="std-mapWithKey">
3390 std.mapWithKey(func, obj)
3391 </h4>
3392 </div>
3393 <div style="clear: both"></div>
3394 </div>
3395 </div>
3396 <div class="hgroup">
3397 <div class="hgroup-inline">
3398 <div class="panel">
3399 <p>
3400 <em>
3401 Available since version 0.10.0.
3402 </em>
3403 </p>
3404 <p>
3405 Apply the given function to all fields of the given object, also passing
3406 the field name. The function <code>func</code> is expected to take the
3407 field name as the first parameter and the field value as the second.
3408 </p>
3409
3410 </div>
3411 <div style="clear: both"></div>
3412 </div>
3413 </div>
3414
3415
3416 <div class="hgroup">
3417 <div class="hgroup-inline">
3418 <div class="panel">
3419 <h3 id="encoding">
3420 Encoding
3421 </h3>
3422 </div>
3423 <div style="clear: both"></div>
3424 </div>
3425 </div>
3426
3427 <div class="hgroup">
3428 <div class="hgroup-inline">
3429 <div class="panel">
3430 <h4 id="std-base64">
3431 std.base64(input)
3432 </h4>
3433 </div>
3434 <div style="clear: both"></div>
3435 </div>
3436 </div>
3437 <div class="hgroup">
3438 <div class="hgroup-inline">
3439 <div class="panel">
3440 <p>
3441 <em>
3442 Available since version 0.10.0.
3443 </em>
3444 </p>
3445 <p>
3446 Encodes the given value into a base64 string. The encoding sequence is <code>A-Za-z0-9+/</code> with
3447 <code>=</code>
3448 to pad the output to a multiple of 4 characters. The value can be a string or an array of
3449 numbers, but the codepoints / numbers must be in the 0 to 255 range. The resulting string
3450 has no line breaks.
3451 </p>
3452
3453 </div>
3454 <div style="clear: both"></div>
3455 </div>
3456 </div>
3457
3458 <div class="hgroup">
3459 <div class="hgroup-inline">
3460 <div class="panel">
3461 <h4 id="std-base64DecodeBytes">
3462 std.base64DecodeBytes(str)
3463 </h4>
3464 </div>
3465 <div style="clear: both"></div>
3466 </div>
3467 </div>
3468 <div class="hgroup">
3469 <div class="hgroup-inline">
3470 <div class="panel">
3471 <p>
3472 <em>
3473 Available since version 0.10.0.
3474 </em>
3475 </p>
3476 <p>
3477 Decodes the given base64 string into an array of bytes (number values). Currently assumes
3478 the input string has no linebreaks and is padded to a multiple of 4 (with the = character).
3479 In other words, it consumes the output of std.base64().
3480 </p>
3481
3482 </div>
3483 <div style="clear: both"></div>
3484 </div>
3485 </div>
3486
3487 <div class="hgroup">
3488 <div class="hgroup-inline">
3489 <div class="panel">
3490 <h4 id="std-base64Decode">
3491 std.base64Decode(str)
3492 </h4>
3493 </div>
3494 <div style="clear: both"></div>
3495 </div>
3496 </div>
3497 <div class="hgroup">
3498 <div class="hgroup-inline">
3499 <div class="panel">
3500 <p>
3501 <em>
3502 Available since version 0.10.0.
3503 </em>
3504 </p>
3505 <p>
3506 <em>Deprecated, use <code>std.base64DecodeBytes</code> and decode the string explicitly (e.g. with <code>std.decodeUTF8</code>) instead.</code></em>
3507 </p>
3508 <p>
3509 Behaves like std.base64DecodeBytes() except returns a naively encoded string instead of an array of bytes.
3510 </p>
3511
3512 </div>
3513 <div style="clear: both"></div>
3514 </div>
3515 </div>
3516
3517 <div class="hgroup">
3518 <div class="hgroup-inline">
3519 <div class="panel">
3520 <h4 id="std-md5">
3521 std.md5(s)
3522 </h4>
3523 </div>
3524 <div style="clear: both"></div>
3525 </div>
3526 </div>
3527 <div class="hgroup">
3528 <div class="hgroup-inline">
3529 <div class="panel">
3530 <p>
3531 <em>
3532 Available since version 0.10.0.
3533 </em>
3534 </p>
3535 <p>
3536 Encodes the given value into an MD5 string.
3537 </p>
3538
3539 </div>
3540 <div style="clear: both"></div>
3541 </div>
3542 </div>
3543
3544 <div class="hgroup">
3545 <div class="hgroup-inline">
3546 <div class="panel">
3547 <h4 id="std-sha1">
3548 std.sha1(s)
3549 </h4>
3550 </div>
3551 <div style="clear: both"></div>
3552 </div>
3553 </div>
3554 <div class="hgroup">
3555 <div class="hgroup-inline">
3556 <div class="panel">
3557 <p>
3558 <em>
3559 Available since version 0.21.0.
3560 </em>
3561 </p>
3562 <p>
3563 Encodes the given value into an SHA1 string.
3564 </p>
3565 <p>
3566 This function is only available in Go version of jsonnet.
3567 </p>
3568
3569 </div>
3570 <div style="clear: both"></div>
3571 </div>
3572 </div>
3573
3574 <div class="hgroup">
3575 <div class="hgroup-inline">
3576 <div class="panel">
3577 <h4 id="std-sha256">
3578 std.sha256(s)
3579 </h4>
3580 </div>
3581 <div style="clear: both"></div>
3582 </div>
3583 </div>
3584 <div class="hgroup">
3585 <div class="hgroup-inline">
3586 <div class="panel">
3587 <p>
3588 <em>
3589 Available since version 0.21.0.
3590 </em>
3591 </p>
3592 <p>
3593 Encodes the given value into an SHA256 string.
3594 </p>
3595 <p>
3596 This function is only available in Go version of jsonnet.
3597 </p>
3598
3599 </div>
3600 <div style="clear: both"></div>
3601 </div>
3602 </div>
3603
3604 <div class="hgroup">
3605 <div class="hgroup-inline">
3606 <div class="panel">
3607 <h4 id="std-sha512">
3608 std.sha512(s)
3609 </h4>
3610 </div>
3611 <div style="clear: both"></div>
3612 </div>
3613 </div>
3614 <div class="hgroup">
3615 <div class="hgroup-inline">
3616 <div class="panel">
3617 <p>
3618 <em>
3619 Available since version 0.21.0.
3620 </em>
3621 </p>
3622 <p>
3623 Encodes the given value into an SHA512 string.
3624 </p>
3625 <p>
3626 This function is only available in Go version of jsonnet.
3627 </p>
3628
3629 </div>
3630 <div style="clear: both"></div>
3631 </div>
3632 </div>
3633
3634 <div class="hgroup">
3635 <div class="hgroup-inline">
3636 <div class="panel">
3637 <h4 id="std-sha3">
3638 std.sha3(s)
3639 </h4>
3640 </div>
3641 <div style="clear: both"></div>
3642 </div>
3643 </div>
3644 <div class="hgroup">
3645 <div class="hgroup-inline">
3646 <div class="panel">
3647 <p>
3648 <em>
3649 Available since version 0.21.0.
3650 </em>
3651 </p>
3652 <p>
3653 Encodes the given value into an SHA3 string.
3654 </p>
3655 <p>
3656 This function is only available in Go version of jsonnet.
3657 </p>
3658
3659 </div>
3660 <div style="clear: both"></div>
3661 </div>
3662 </div>
3663
3664
3665 <div class="hgroup">
3666 <div class="hgroup-inline">
3667 <div class="panel">
3668 <h3 id="booleans">
3669 Booleans
3670 </h3>
3671 </div>
3672 <div style="clear: both"></div>
3673 </div>
3674 </div>
3675
3676 <div class="hgroup">
3677 <div class="hgroup-inline">
3678 <div class="panel">
3679 <h4 id="std-xor">
3680 std.xor(x, y)
3681 </h4>
3682 </div>
3683 <div style="clear: both"></div>
3684 </div>
3685 </div>
3686 <div class="hgroup">
3687 <div class="hgroup-inline">
3688 <div class="panel">
3689 <p>
3690 <em>
3691 Available since version 0.20.0.
3692 </em>
3693 </p>
3694 <p>
3695 Returns the xor of the two given booleans.
3696 </p>
3697
3698 </div>
3699 <div style="clear: both"></div>
3700 </div>
3701 </div>
3702
3703 <div class="hgroup">
3704 <div class="hgroup-inline">
3705 <div class="panel">
3706 <h4 id="std-xnor">
3707 std.xnor(x, y)
3708 </h4>
3709 </div>
3710 <div style="clear: both"></div>
3711 </div>
3712 </div>
3713 <div class="hgroup">
3714 <div class="hgroup-inline">
3715 <div class="panel">
3716 <p>
3717 <em>
3718 Available since version 0.20.0.
3719 </em>
3720 </p>
3721 <p>
3722 Returns the xnor of the two given booleans.
3723 </p>
3724
3725 </div>
3726 <div style="clear: both"></div>
3727 </div>
3728 </div>
3729
3730
3731 <div class="hgroup">
3732 <div class="hgroup-inline">
3733 <div class="panel">
3734 <h3 id="json_merge_patch">
3735 JSON Merge Patch
3736 </h3>
3737 </div>
3738 <div style="clear: both"></div>
3739 </div>
3740 </div>
3741
3742 <div class="hgroup">
3743 <div class="hgroup-inline">
3744 <div class="panel">
3745 <h4 id="std-mergePatch">
3746 std.mergePatch(target, patch)
3747 </h4>
3748 </div>
3749 <div style="clear: both"></div>
3750 </div>
3751 </div>
3752 <div class="hgroup">
3753 <div class="hgroup-inline">
3754 <div class="panel">
3755 <p>
3756 <em>
3757 Available since version 0.10.0.
3758 </em>
3759 </p>
3760 <p>
3761 Applies <code>patch</code> to <code>target</code>
3762 according to <a href="https://tools.ietf.org/html/rfc7396">RFC7396</a>
3763 </p>
3764
3765 </div>
3766 <div style="clear: both"></div>
3767 </div>
3768 </div>
3769
3770
3771 <div class="hgroup">
3772 <div class="hgroup-inline">
3773 <div class="panel">
3774 <h3 id="debugging">
3775 Debugging
3776 </h3>
3777 </div>
3778 <div style="clear: both"></div>
3779 </div>
3780 </div>
3781
3782 <div class="hgroup">
3783 <div class="hgroup-inline">
3784 <div class="panel">
3785 <h4 id="std-trace">
3786 std.trace(str, rest)
3787 </h4>
3788 </div>
3789 <div style="clear: both"></div>
3790 </div>
3791 </div>
3792 <div class="hgroup">
3793 <div class="hgroup-inline">
3794 <div class="panel">
3795 <p>
3796 <em>
3797 Available since version 0.11.0.
3798 </em>
3799 </p>
3800 <p>
3801 Outputs the given string <code>str</code> to stderr and
3802 returns <code>rest</code> as the result.
3803 </p>
3804 <p>
3805 Example:
3806 </p>
3807 <p>
3808 <pre>local conditionalReturn(cond, in1, in2) =
3809 if (cond) then
3810 std.trace('cond is true returning '
3811 + std.toString(in1), in1)
3812 else
3813 std.trace('cond is false returning '
3814 + std.toString(in2), in2);
3815
3816 {
3817 a: conditionalReturn(true, { b: true }, { c: false }),
3818 }</pre>
3819 </p>
3820 <p>
3821 Prints:
3822 </p>
3823 <p>
3824 <pre>TRACE: test.jsonnet:3 cond is true returning {"b": true}
3825 {
3826 "a": {
3827 "b": true
3828 }
3829 }</pre>
3830 </p>
3831
3832 </div>
3833 <div style="clear: both"></div>
3834 </div>
3835 </div>
3836
3837