Debian Codegraph @

doc/ref/stdlib.html

raw symbols SCIP
1 ---
2 # AUTOGENERATED FILE. DO NOT EDIT BY HAND!
3 layout: default
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="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 string 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="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="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="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="get">
187 std.get(o, f, default=null, inc_hidden=true)
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.18.0.
199 </em>
200 </p>
201 <p>
202 Returns the object's field if it exists or default value otherwise.
203 <code>inc_hidden</code> controls whether to include hidden fields.
204 </p>
205
206 </div>
207 <div style="clear: both"></div>
208 </div>
209 </div>
210
211 <div class="hgroup">
212 <div class="hgroup-inline">
213 <div class="panel">
214 <h4 id="objectHas">
215 std.objectHas(o, f)
216 </h4>
217 </div>
218 <div style="clear: both"></div>
219 </div>
220 </div>
221 <div class="hgroup">
222 <div class="hgroup-inline">
223 <div class="panel">
224 <p>
225 <em>
226 Available since version 0.10.0.
227 </em>
228 </p>
229 <p>
230 Returns <code>true</code> if the given object has the field (given as a string), otherwise
231 <code>false</code>. Raises an error if the arguments are not object and string
232 respectively. Returns false if the field is hidden.
233 </p>
234
235 </div>
236 <div style="clear: both"></div>
237 </div>
238 </div>
239
240 <div class="hgroup">
241 <div class="hgroup-inline">
242 <div class="panel">
243 <h4 id="objectFields">
244 std.objectFields(o)
245 </h4>
246 </div>
247 <div style="clear: both"></div>
248 </div>
249 </div>
250 <div class="hgroup">
251 <div class="hgroup-inline">
252 <div class="panel">
253 <p>
254 <em>
255 Available since version 0.10.0.
256 </em>
257 </p>
258 <p>
259 Returns an array of strings, each element being a field from the given object. Does not include
260 hidden fields.
261 </p>
262
263 </div>
264 <div style="clear: both"></div>
265 </div>
266 </div>
267
268 <div class="hgroup">
269 <div class="hgroup-inline">
270 <div class="panel">
271 <h4 id="objectValues">
272 std.objectValues(o)
273 </h4>
274 </div>
275 <div style="clear: both"></div>
276 </div>
277 </div>
278 <div class="hgroup">
279 <div class="hgroup-inline">
280 <div class="panel">
281 <p>
282 <em>
283 Available since version 0.17.0.
284 </em>
285 </p>
286 <p>
287 Returns an array of the values in the given object. Does not include hidden fields.
288 </p>
289
290 </div>
291 <div style="clear: both"></div>
292 </div>
293 </div>
294
295 <div class="hgroup">
296 <div class="hgroup-inline">
297 <div class="panel">
298 <h4 id="objectKeysValues">
299 std.objectKeysValues(o)
300 </h4>
301 </div>
302 <div style="clear: both"></div>
303 </div>
304 </div>
305 <div class="hgroup">
306 <div class="hgroup-inline">
307 <div class="panel">
308 <p>
309 <em>
310 Available in upcoming release.
311 </em>
312 </p>
313 <p>
314 Returns an array of objects from the given object, each object having two fields:
315 <code>key</code> (string) and <code>value</code> (object). Does not include hidden fields.
316 </p>
317
318 </div>
319 <div style="clear: both"></div>
320 </div>
321 </div>
322
323 <div class="hgroup">
324 <div class="hgroup-inline">
325 <div class="panel">
326 <h4 id="objectHasAll">
327 std.objectHasAll(o, f)
328 </h4>
329 </div>
330 <div style="clear: both"></div>
331 </div>
332 </div>
333 <div class="hgroup">
334 <div class="hgroup-inline">
335 <div class="panel">
336 <p>
337 <em>
338 Available since version 0.10.0.
339 </em>
340 </p>
341 <p>
342 As <code>std.objectHas</code> but also includes hidden fields.
343 </p>
344
345 </div>
346 <div style="clear: both"></div>
347 </div>
348 </div>
349
350 <div class="hgroup">
351 <div class="hgroup-inline">
352 <div class="panel">
353 <h4 id="objectFieldsAll">
354 std.objectFieldsAll(o)
355 </h4>
356 </div>
357 <div style="clear: both"></div>
358 </div>
359 </div>
360 <div class="hgroup">
361 <div class="hgroup-inline">
362 <div class="panel">
363 <p>
364 <em>
365 Available since version 0.10.0.
366 </em>
367 </p>
368 <p>
369 As <code>std.objectFields</code> but also includes hidden fields.
370 </p>
371
372 </div>
373 <div style="clear: both"></div>
374 </div>
375 </div>
376
377 <div class="hgroup">
378 <div class="hgroup-inline">
379 <div class="panel">
380 <h4 id="objectValuesAll">
381 std.objectValuesAll(o)
382 </h4>
383 </div>
384 <div style="clear: both"></div>
385 </div>
386 </div>
387 <div class="hgroup">
388 <div class="hgroup-inline">
389 <div class="panel">
390 <p>
391 <em>
392 Available since version 0.17.0.
393 </em>
394 </p>
395 <p>
396 As <code>std.objectValues</code> but also includes hidden fields.
397 </p>
398
399 </div>
400 <div style="clear: both"></div>
401 </div>
402 </div>
403
404 <div class="hgroup">
405 <div class="hgroup-inline">
406 <div class="panel">
407 <h4 id="objectKeysValuesAll">
408 std.objectKeysValuesAll(o)
409 </h4>
410 </div>
411 <div style="clear: both"></div>
412 </div>
413 </div>
414 <div class="hgroup">
415 <div class="hgroup-inline">
416 <div class="panel">
417 <p>
418 <em>
419 Available in upcoming release.
420 </em>
421 </p>
422 <p>
423 As <code>std.objectKeysValues</code> but also includes hidden fields.
424 </p>
425
426 </div>
427 <div style="clear: both"></div>
428 </div>
429 </div>
430
431 <div class="hgroup">
432 <div class="hgroup-inline">
433 <div class="panel">
434 <h4 id="prune">
435 std.prune(a)
436 </h4>
437 </div>
438 <div style="clear: both"></div>
439 </div>
440 </div>
441 <div class="hgroup">
442 <div class="hgroup-inline">
443 <div class="panel">
444 <p>
445 <em>
446 Available since version 0.10.0.
447 </em>
448 </p>
449 <p>
450 Recursively remove all "empty" members of <code>a</code>. "Empty" is defined as zero
451 length `arrays`, zero length `objects`, or `null` values.
452 The argument <code>a</code> may have any type.
453 </p>
454
455 </div>
456 <div style="clear: both"></div>
457 </div>
458 </div>
459
460 <div class="hgroup">
461 <div class="hgroup-inline">
462 <div class="panel">
463 <h4 id="mapWithKey">
464 std.mapWithKey(func, obj)
465 </h4>
466 </div>
467 <div style="clear: both"></div>
468 </div>
469 </div>
470 <div class="hgroup">
471 <div class="hgroup-inline">
472 <div class="panel">
473 <p>
474 <em>
475 Available since version 0.10.0.
476 </em>
477 </p>
478 <p>
479 Apply the given function to all fields of the given object, also passing
480 the field name. The function <code>func</code> is expected to take the
481 field name as the first parameter and the field value as the second.
482 </p>
483
484 </div>
485 <div style="clear: both"></div>
486 </div>
487 </div>
488
489
490 <div class="hgroup">
491 <div class="hgroup-inline">
492 <div class="panel">
493 <h3 id="math">
494 Mathematical Utilities
495 </h3>
496 </div>
497 <div style="clear: both"></div>
498 </div>
499 </div>
500 <div class="hgroup">
501 <div class="hgroup-inline">
502 <div class="panel">
503 <p>
504 The following mathematical functions are available:
505 </p>
506 <ul>
507 <ul><code>std.abs(n)</code></ul>
508 <ul><code>std.sign(n)</code></ul>
509 <ul><code>std.max(a, b)</code></ul>
510 <ul><code>std.min(a, b)</code></ul>
511 <ul><code>std.pow(x, n)</code></ul>
512 <ul><code>std.exp(x)</code></ul>
513 <ul><code>std.log(x)</code></ul>
514 <ul><code>std.exponent(x)</code></ul>
515 <ul><code>std.mantissa(x)</code></ul>
516 <ul><code>std.floor(x)</code></ul>
517 <ul><code>std.ceil(x)</code></ul>
518 <ul><code>std.sqrt(x)</code></ul>
519 <ul><code>std.sin(x)</code></ul>
520 <ul><code>std.cos(x)</code></ul>
521 <ul><code>std.tan(x)</code></ul>
522 <ul><code>std.asin(x)</code></ul>
523 <ul><code>std.acos(x)</code></ul>
524 <ul><code>std.atan(x)</code></ul>
525 <ul><code>std.round(x)</code></ul>
526 </ul>
527 <p>
528 The function <code>std.mod(a, b)</code> is what the % operator is desugared to. It performs
529 modulo arithmetic if the left hand side is a number, or if the left hand side is a string,
530 it does Python-style string formatting with <code>std.format()</code>.
531 </p>
532 </div>
533 <div style="clear: both"></div>
534 </div>
535 </div>
536
537 <div class="hgroup">
538 <div class="hgroup-inline">
539 <div class="panel">
540 <h4 id="clamp">
541 std.clamp(x, minVal, maxVal)
542 </h4>
543 </div>
544 <div style="clear: both"></div>
545 </div>
546 </div>
547 <div class="hgroup">
548 <div class="hgroup-inline">
549 <div class="panel">
550 <p>
551 <em>
552 Available since version 0.15.0.
553 </em>
554 </p>
555 <p>
556 Clamp a value to fit within the range [<code>minVal</code>, <code>maxVal</code>].
557 Equivalent to <code>std.max(minVal, std.min(x, maxVal))</code>.
558 </p>
559 <p>
560 Example: <code>std.clamp(-3, 0, 5)</code> yields <code>0</code>.
561 </p>
562 <p>
563 Example: <code>std.clamp(4, 0, 5)</code> yields <code>4</code>.
564 </p>
565 <p>
566 Example: <code>std.clamp(7, 0, 5)</code> yields <code>5</code>.
567 </p>
568 </div>
569 <div style="clear: both"></div>
570 </div>
571 </div>
572
573
574 <div class="hgroup">
575 <div class="hgroup-inline">
576 <div class="panel">
577 <h3 id="assertions_debugging">
578 Assertions and Debugging
579 </h3>
580 </div>
581 <div style="clear: both"></div>
582 </div>
583 </div>
584
585 <div class="hgroup">
586 <div class="hgroup-inline">
587 <div class="panel">
588 <h4 id="assertEqual">
589 std.assertEqual(a, b)
590 </h4>
591 </div>
592 <div style="clear: both"></div>
593 </div>
594 </div>
595 <div class="hgroup">
596 <div class="hgroup-inline">
597 <div class="panel">
598 <p>
599 <em>
600 Available since version 0.10.0.
601 </em>
602 </p>
603 <p>
604 Ensure that <code>a == b</code>. Returns <code>true</code> or throws an error message.
605 </p>
606
607 </div>
608 <div style="clear: both"></div>
609 </div>
610 </div>
611
612
613 <div class="hgroup">
614 <div class="hgroup-inline">
615 <div class="panel">
616 <h3 id="string">
617 String Manipulation
618 </h3>
619 </div>
620 <div style="clear: both"></div>
621 </div>
622 </div>
623
624 <div class="hgroup">
625 <div class="hgroup-inline">
626 <div class="panel">
627 <h4 id="toString">
628 std.toString(a)
629 </h4>
630 </div>
631 <div style="clear: both"></div>
632 </div>
633 </div>
634 <div class="hgroup">
635 <div class="hgroup-inline">
636 <div class="panel">
637 <p>
638 <em>
639 Available since version 0.10.0.
640 </em>
641 </p>
642 <p>
643 Convert the given argument to a string.
644 </p>
645
646 </div>
647 <div style="clear: both"></div>
648 </div>
649 </div>
650
651 <div class="hgroup">
652 <div class="hgroup-inline">
653 <div class="panel">
654 <h4 id="codepoint">
655 std.codepoint(str)
656 </h4>
657 </div>
658 <div style="clear: both"></div>
659 </div>
660 </div>
661 <div class="hgroup">
662 <div class="hgroup-inline">
663 <div class="panel">
664 <p>
665 <em>
666 Available since version 0.10.0.
667 </em>
668 </p>
669 <p>
670 Returns the positive integer representing the unicode codepoint of the character in the
671 given single-character string. This function is the inverse of <code>std.char(n)</code>.
672 </p>
673
674 </div>
675 <div style="clear: both"></div>
676 </div>
677 </div>
678
679 <div class="hgroup">
680 <div class="hgroup-inline">
681 <div class="panel">
682 <h4 id="char">
683 std.char(n)
684 </h4>
685 </div>
686 <div style="clear: both"></div>
687 </div>
688 </div>
689 <div class="hgroup">
690 <div class="hgroup-inline">
691 <div class="panel">
692 <p>
693 <em>
694 Available since version 0.10.0.
695 </em>
696 </p>
697 <p>
698 Returns a string of length one whose only unicode codepoint has integer id <code>n</code>.
699 This function is the inverse of <code>std.codepoint(str)</code>.
700 </p>
701
702 </div>
703 <div style="clear: both"></div>
704 </div>
705 </div>
706
707 <div class="hgroup">
708 <div class="hgroup-inline">
709 <div class="panel">
710 <h4 id="substr">
711 std.substr(str, from, len)
712 </h4>
713 </div>
714 <div style="clear: both"></div>
715 </div>
716 </div>
717 <div class="hgroup">
718 <div class="hgroup-inline">
719 <div class="panel">
720 <p>
721 <em>
722 Available since version 0.10.0.
723 </em>
724 </p>
725 <p>
726 Returns a string that is the part of <code>s</code> that starts at offset <code>from</code>
727 and is <code>len</code> codepoints long. If the string <code>s</code> is shorter than
728 <code>from+len</code>, the suffix starting at position <code>from</code> will be returned.
729 </p>
730
731 </div>
732 <div style="clear: both"></div>
733 </div>
734 </div>
735
736 <div class="hgroup">
737 <div class="hgroup-inline">
738 <div class="panel">
739 <h4 id="findSubstr">
740 std.findSubstr(pat, str)
741 </h4>
742 </div>
743 <div style="clear: both"></div>
744 </div>
745 </div>
746 <div class="hgroup">
747 <div class="hgroup-inline">
748 <div class="panel">
749 <p>
750 <em>
751 Available since version 0.10.0.
752 </em>
753 </p>
754 <p>
755 Returns an array that contains the indexes of all occurrences of <code>pat</code> in
756 <code>str</code>.
757 </p>
758
759 </div>
760 <div style="clear: both"></div>
761 </div>
762 </div>
763
764 <div class="hgroup">
765 <div class="hgroup-inline">
766 <div class="panel">
767 <h4 id="startsWith">
768 std.startsWith(a, b)
769 </h4>
770 </div>
771 <div style="clear: both"></div>
772 </div>
773 </div>
774 <div class="hgroup">
775 <div class="hgroup-inline">
776 <div class="panel">
777 <p>
778 <em>
779 Available since version 0.10.0.
780 </em>
781 </p>
782 <p>
783 Returns whether the string a is prefixed by the string b.
784 </p>
785
786 </div>
787 <div style="clear: both"></div>
788 </div>
789 </div>
790
791 <div class="hgroup">
792 <div class="hgroup-inline">
793 <div class="panel">
794 <h4 id="endsWith">
795 std.endsWith(a, b)
796 </h4>
797 </div>
798 <div style="clear: both"></div>
799 </div>
800 </div>
801 <div class="hgroup">
802 <div class="hgroup-inline">
803 <div class="panel">
804 <p>
805 <em>
806 Available since version 0.10.0.
807 </em>
808 </p>
809 <p>
810 Returns whether the string a is suffixed by the string b.
811 </p>
812
813 </div>
814 <div style="clear: both"></div>
815 </div>
816 </div>
817
818 <div class="hgroup">
819 <div class="hgroup-inline">
820 <div class="panel">
821 <h4 id="stripChars">
822 std.stripChars(str, chars)
823 </h4>
824 </div>
825 <div style="clear: both"></div>
826 </div>
827 </div>
828 <div class="hgroup">
829 <div class="hgroup-inline">
830 <div class="panel">
831 <p>
832 <em>
833 Available since version 0.15.0.
834 </em>
835 </p>
836 <p>
837 Removes characters <code>chars</code> from the beginning and from the end of <code>str</code>.
838 </p>
839 <p>
840 Example: <code>std.stripChars(" test test test ", " ")</code> yields <code>"test test test"</code>.
841 </p>
842 <p>
843 Example: <code>std.stripChars("aaabbbbcccc", "ac")</code> yields <code>"bbbb"</code>.
844 </p>
845 <p>
846 Example: <code>std.stripChars("cacabbbbaacc", "ac")</code> yields <code>"bbbb"</code>.
847 </p>
848 </div>
849 <div style="clear: both"></div>
850 </div>
851 </div>
852
853 <div class="hgroup">
854 <div class="hgroup-inline">
855 <div class="panel">
856 <h4 id="lstripChars">
857 std.lstripChars(str, chars)
858 </h4>
859 </div>
860 <div style="clear: both"></div>
861 </div>
862 </div>
863 <div class="hgroup">
864 <div class="hgroup-inline">
865 <div class="panel">
866 <p>
867 <em>
868 Available since version 0.15.0.
869 </em>
870 </p>
871 <p>
872 Removes characters <code>chars</code> from the beginning of <code>str</code>.
873 </p>
874 <p>
875 Example: <code>std.lstripChars(" test test test ", " ")</code> yields <code>"test test test "</code>.
876 </p>
877 <p>
878 Example: <code>std.lstripChars("aaabbbbcccc", "ac")</code> yields <code>"bbbbcccc"</code>.
879 </p>
880 <p>
881 Example: <code>std.lstripChars("cacabbbbaacc", "ac")</code> yields <code>"bbbbaacc"</code>.
882 </p>
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="rstripChars">
892 std.rstripChars(str, chars)
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.15.0.
904 </em>
905 </p>
906 <p>
907 Removes characters <code>chars</code> from the end of <code>str</code>.
908 </p>
909 <p>
910 Example: <code>std.rstripChars(" test test test ", " ")</code> yields <code>" test test test"</code>.
911 </p>
912 <p>
913 Example: <code>std.rstripChars("aaabbbbcccc", "ac")</code> yields <code>"aaabbbb"</code>.
914 </p>
915 <p>
916 Example: <code>std.rstripChars("cacabbbbaacc", "ac")</code> yields <code>"cacabbbb"</code>.
917 </p>
918 </div>
919 <div style="clear: both"></div>
920 </div>
921 </div>
922
923 <div class="hgroup">
924 <div class="hgroup-inline">
925 <div class="panel">
926 <h4 id="split">
927 std.split(str, c)
928 </h4>
929 </div>
930 <div style="clear: both"></div>
931 </div>
932 </div>
933 <div class="hgroup">
934 <div class="hgroup-inline">
935 <div class="panel">
936 <p>
937 <em>
938 Available since version 0.10.0.
939 </em>
940 </p>
941 <p>
942 Split the string <code>str</code> into an array of strings, divided by the string
943 <code>c</code>.
944 </p>
945 <p>
946 Note: Versions up to and including 0.18.0 require <code>c</code> to be a single character.
947 </p>
948 <p>
949 Example: <code>std.split("foo/_bar", "/_")</code> yields <code>[ "foo", "bar" ]</code>.
950 </p>
951 <p>
952 Example: <code>std.split("/_foo/_bar", "/_")</code> yields <code>[ "", "foo", "bar" ]</code>.
953 </p>
954 </div>
955 <div style="clear: both"></div>
956 </div>
957 </div>
958
959 <div class="hgroup">
960 <div class="hgroup-inline">
961 <div class="panel">
962 <h4 id="splitLimit">
963 std.splitLimit(str, c, maxsplits)
964 </h4>
965 </div>
966 <div style="clear: both"></div>
967 </div>
968 </div>
969 <div class="hgroup">
970 <div class="hgroup-inline">
971 <div class="panel">
972 <p>
973 <em>
974 Available since version 0.10.0.
975 </em>
976 </p>
977 <p>
978 As <code>std.split(str, c)</code> but will stop after <code>maxsplits</code> splits, thereby the largest
979 array it will return has length <code>maxsplits + 1</code>. A limit of <code>-1</code> means unlimited.
980 </p>
981 <p>
982 Note: Versions up to and including 0.18.0 require <code>c</code> to be a single character.
983 </p>
984 <p>
985 Example: <code>std.splitLimit("foo/_bar", "/_", 1)</code> yields <code>[ "foo", "bar" ]</code>.
986 </p>
987 <p>
988 Example: <code>std.splitLimit("/_foo/_bar", "/_", 1)</code> yields <code>[ "", "foo/_bar" ]</code>.
989 </p>
990 </div>
991 <div style="clear: both"></div>
992 </div>
993 </div>
994
995 <div class="hgroup">
996 <div class="hgroup-inline">
997 <div class="panel">
998 <h4 id="splitLimitR">
999 std.splitLimitR(str, c, maxsplits)
1000 </h4>
1001 </div>
1002 <div style="clear: both"></div>
1003 </div>
1004 </div>
1005 <div class="hgroup">
1006 <div class="hgroup-inline">
1007 <div class="panel">
1008 <p>
1009 <em>
1010 Available since version 0.19.0.
1011 </em>
1012 </p>
1013 <p>
1014 As <code>std.splitLimit(str, c, maxsplits)</code> but will split from right to left.
1015 </p>
1016 <p>
1017 Example: <code>std.splitLimitR("/_foo/_bar", "/_", 1)</code> yields <code>[ "/_foo", "bar" ]</code>.
1018 </p>
1019 </div>
1020 <div style="clear: both"></div>
1021 </div>
1022 </div>
1023
1024 <div class="hgroup">
1025 <div class="hgroup-inline">
1026 <div class="panel">
1027 <h4 id="strReplace">
1028 std.strReplace(str, from, to)
1029 </h4>
1030 </div>
1031 <div style="clear: both"></div>
1032 </div>
1033 </div>
1034 <div class="hgroup">
1035 <div class="hgroup-inline">
1036 <div class="panel">
1037 <p>
1038 <em>
1039 Available since version 0.10.0.
1040 </em>
1041 </p>
1042 <p>
1043 Returns a copy of the string in which all occurrences of string <code>from</code> have been
1044 replaced with string <code>to</code>.
1045 </p>
1046 <p>
1047 Example: <code>std.strReplace('I like to skate with my skateboard', 'skate', 'surf')</code> yields <code>"I like to surf with my surfboard"</code>.
1048 </p>
1049 </div>
1050 <div style="clear: both"></div>
1051 </div>
1052 </div>
1053
1054 <div class="hgroup">
1055 <div class="hgroup-inline">
1056 <div class="panel">
1057 <h4 id="isEmpty">
1058 std.isEmpty(str)
1059 </h4>
1060 </div>
1061 <div style="clear: both"></div>
1062 </div>
1063 </div>
1064 <div class="hgroup">
1065 <div class="hgroup-inline">
1066 <div class="panel">
1067 <p>
1068 <em>
1069 Available in upcoming release.
1070 </em>
1071 </p>
1072 <p>
1073 Returns true if the the given string is of zero length.
1074 </p>
1075
1076 </div>
1077 <div style="clear: both"></div>
1078 </div>
1079 </div>
1080
1081 <div class="hgroup">
1082 <div class="hgroup-inline">
1083 <div class="panel">
1084 <h4 id="asciiUpper">
1085 std.asciiUpper(str)
1086 </h4>
1087 </div>
1088 <div style="clear: both"></div>
1089 </div>
1090 </div>
1091 <div class="hgroup">
1092 <div class="hgroup-inline">
1093 <div class="panel">
1094 <p>
1095 <em>
1096 Available since version 0.10.0.
1097 </em>
1098 </p>
1099 <p>
1100 Returns a copy of the string in which all ASCII letters are capitalized.
1101 </p>
1102 <p>
1103 Example: <code>std.asciiUpper('100 Cats!')</code> yields <code>"100 CATS!"</code>.
1104 </p>
1105 </div>
1106 <div style="clear: both"></div>
1107 </div>
1108 </div>
1109
1110 <div class="hgroup">
1111 <div class="hgroup-inline">
1112 <div class="panel">
1113 <h4 id="asciiLower">
1114 std.asciiLower(str)
1115 </h4>
1116 </div>
1117 <div style="clear: both"></div>
1118 </div>
1119 </div>
1120 <div class="hgroup">
1121 <div class="hgroup-inline">
1122 <div class="panel">
1123 <p>
1124 <em>
1125 Available since version 0.10.0.
1126 </em>
1127 </p>
1128 <p>
1129 Returns a copy of the string in which all ASCII letters are lower cased.
1130 </p>
1131 <p>
1132 Example: <code>std.asciiLower('100 Cats!')</code> yields <code>"100 cats!"</code>.
1133 </p>
1134 </div>
1135 <div style="clear: both"></div>
1136 </div>
1137 </div>
1138
1139 <div class="hgroup">
1140 <div class="hgroup-inline">
1141 <div class="panel">
1142 <h4 id="stringChars">
1143 std.stringChars(str)
1144 </h4>
1145 </div>
1146 <div style="clear: both"></div>
1147 </div>
1148 </div>
1149 <div class="hgroup">
1150 <div class="hgroup-inline">
1151 <div class="panel">
1152 <p>
1153 <em>
1154 Available since version 0.10.0.
1155 </em>
1156 </p>
1157 <p>
1158 Split the string <code>str</code> into an array of strings, each containing a single
1159 codepoint.
1160 </p>
1161 <p>
1162 Example: <code>std.stringChars("foo")</code> yields <code>[ "f", "o", "o" ]</code>.
1163 </p>
1164 </div>
1165 <div style="clear: both"></div>
1166 </div>
1167 </div>
1168
1169 <div class="hgroup">
1170 <div class="hgroup-inline">
1171 <div class="panel">
1172 <h4 id="format">
1173 std.format(str, vals)
1174 </h4>
1175 </div>
1176 <div style="clear: both"></div>
1177 </div>
1178 </div>
1179 <div class="hgroup">
1180 <div class="hgroup-inline">
1181 <div class="panel">
1182 <p>
1183 <em>
1184 Available since version 0.10.0.
1185 </em>
1186 </p>
1187 <p>
1188 Format the string <code>str</code> using the values in <code>vals</code>. The values can be
1189 an array, an object, or in other cases are treated as if they were provided in a singleton
1190 array. The string formatting follows the <a
1191 href="https://docs.python.org/2/library/stdtypes.html#string-formatting">same rules</a> as
1192 Python. The <code>%</code> operator can be used as a shorthand for this function.
1193 </p>
1194 <p>
1195 Example: <code>std.format("Hello %03d", 12)</code> yields <code>"Hello 012"</code>.
1196 </p>
1197 <p>
1198 Example: <code>"Hello %03d" % 12</code> yields <code>"Hello 012"</code>.
1199 </p>
1200 <p>
1201 Example: <code>"Hello %s, age %d" % ["Foo", 25]</code> yields <code>"Hello Foo, age 25"</code>.
1202 </p>
1203 <p>
1204 Example: <code>"Hello %(name)s, age %(age)d" % {age: 25, name: "Foo"}</code> yields <code>"Hello Foo, age 25"</code>.
1205 </p>
1206 </div>
1207 <div style="clear: both"></div>
1208 </div>
1209 </div>
1210
1211 <div class="hgroup">
1212 <div class="hgroup-inline">
1213 <div class="panel">
1214 <h4 id="escapeStringBash">
1215 std.escapeStringBash(str)
1216 </h4>
1217 </div>
1218 <div style="clear: both"></div>
1219 </div>
1220 </div>
1221 <div class="hgroup">
1222 <div class="hgroup-inline">
1223 <div class="panel">
1224 <p>
1225 <em>
1226 Available since version 0.10.0.
1227 </em>
1228 </p>
1229 <p>
1230 Wrap <code>str</code> in single quotes, and escape any single quotes within <code>str</code>
1231 by changing them to a sequence <tt>'"'"'</tt>. This allows injection of arbitrary strings
1232 as arguments of commands in bash scripts.
1233 </p>
1234
1235 </div>
1236 <div style="clear: both"></div>
1237 </div>
1238 </div>
1239
1240 <div class="hgroup">
1241 <div class="hgroup-inline">
1242 <div class="panel">
1243 <h4 id="escapeStringDollars">
1244 std.escapeStringDollars(str)
1245 </h4>
1246 </div>
1247 <div style="clear: both"></div>
1248 </div>
1249 </div>
1250 <div class="hgroup">
1251 <div class="hgroup-inline">
1252 <div class="panel">
1253 <p>
1254 <em>
1255 Available since version 0.10.0.
1256 </em>
1257 </p>
1258 <p>
1259 Convert $ to $$ in <code>str</code>. This allows injection of arbitrary strings into
1260 systems that use $ for string interpolation (like Terraform).
1261 </p>
1262
1263 </div>
1264 <div style="clear: both"></div>
1265 </div>
1266 </div>
1267
1268 <div class="hgroup">
1269 <div class="hgroup-inline">
1270 <div class="panel">
1271 <h4 id="escapeStringJson">
1272 std.escapeStringJson(str)
1273 </h4>
1274 </div>
1275 <div style="clear: both"></div>
1276 </div>
1277 </div>
1278 <div class="hgroup">
1279 <div class="hgroup-inline">
1280 <div class="panel">
1281 <p>
1282 <em>
1283 Available since version 0.10.0.
1284 </em>
1285 </p>
1286 <p>
1287 Convert <code>str</code> to allow it to be embedded in a JSON representation, within a
1288 string. This adds quotes, escapes backslashes, and escapes unprintable characters.
1289 </p>
1290 <p>
1291 Example: <code>local description = "Multiline\nc:\\path";
1292 "{name: %s}" % std.escapeStringJson(description)</code> yields <code>"{name: \"Multiline\\nc:\\\\path\"}"</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="escapeStringPython">
1303 std.escapeStringPython(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.10.0.
1315 </em>
1316 </p>
1317 <p>
1318 Convert <code>str</code> to allow it to be embedded in Python. This is an alias for
1319 <code>std.escapeStringJson</code>.
1320 </p>
1321
1322 </div>
1323 <div style="clear: both"></div>
1324 </div>
1325 </div>
1326
1327 <div class="hgroup">
1328 <div class="hgroup-inline">
1329 <div class="panel">
1330 <h4 id="escapeStringXml">
1331 std.escapeStringXml(str)
1332 </h4>
1333 </div>
1334 <div style="clear: both"></div>
1335 </div>
1336 </div>
1337 <div class="hgroup">
1338 <div class="hgroup-inline">
1339 <div class="panel">
1340 <p>
1341 <em>
1342 Available since version 0.10.0.
1343 </em>
1344 </p>
1345 <p>
1346 Convert <code>str</code> to allow it to be embedded in XML (or HTML). The following replacements are made:
1347 <pre>
1348 {
1349 "&lt;": "&amp;lt;",
1350 "&gt;": "&amp;gt;",
1351 "&amp;": "&amp;amp;",
1352 "\&quot;": "&amp;quot;",
1353 "&apos;": "&amp;apos;",
1354 }
1355 </pre>
1356 </p>
1357
1358 </div>
1359 <div style="clear: both"></div>
1360 </div>
1361 </div>
1362
1363
1364 <div class="hgroup">
1365 <div class="hgroup-inline">
1366 <div class="panel">
1367 <h3 id="parsing">
1368 Parsing
1369 </h3>
1370 </div>
1371 <div style="clear: both"></div>
1372 </div>
1373 </div>
1374
1375 <div class="hgroup">
1376 <div class="hgroup-inline">
1377 <div class="panel">
1378 <h4 id="parseInt">
1379 std.parseInt(str)
1380 </h4>
1381 </div>
1382 <div style="clear: both"></div>
1383 </div>
1384 </div>
1385 <div class="hgroup">
1386 <div class="hgroup-inline">
1387 <div class="panel">
1388 <p>
1389 <em>
1390 Available since version 0.10.0.
1391 </em>
1392 </p>
1393 <p>
1394 Parses a signed decimal integer from the input string.
1395 </p>
1396 <p>
1397 Example: <code>std.parseInt("123")</code> yields <code>123</code>.
1398 </p>
1399 <p>
1400 Example: <code>std.parseInt("-123")</code> yields <code>-123</code>.
1401 </p>
1402 </div>
1403 <div style="clear: both"></div>
1404 </div>
1405 </div>
1406
1407 <div class="hgroup">
1408 <div class="hgroup-inline">
1409 <div class="panel">
1410 <h4 id="parseOctal">
1411 std.parseOctal(str)
1412 </h4>
1413 </div>
1414 <div style="clear: both"></div>
1415 </div>
1416 </div>
1417 <div class="hgroup">
1418 <div class="hgroup-inline">
1419 <div class="panel">
1420 <p>
1421 <em>
1422 Available since version 0.10.0.
1423 </em>
1424 </p>
1425 <p>
1426 Parses an unsigned octal integer from the input string. Initial zeroes are tolerated.
1427 </p>
1428 <p>
1429 Example: <code>std.parseOctal("755")</code> yields <code>493</code>.
1430 </p>
1431 </div>
1432 <div style="clear: both"></div>
1433 </div>
1434 </div>
1435
1436 <div class="hgroup">
1437 <div class="hgroup-inline">
1438 <div class="panel">
1439 <h4 id="parseHex">
1440 std.parseHex(str)
1441 </h4>
1442 </div>
1443 <div style="clear: both"></div>
1444 </div>
1445 </div>
1446 <div class="hgroup">
1447 <div class="hgroup-inline">
1448 <div class="panel">
1449 <p>
1450 <em>
1451 Available since version 0.10.0.
1452 </em>
1453 </p>
1454 <p>
1455 Parses an unsigned hexadecimal integer, from the input string. Case insensitive.
1456 </p>
1457 <p>
1458 Example: <code>std.parseHex("ff")</code> yields <code>255</code>.
1459 </p>
1460 </div>
1461 <div style="clear: both"></div>
1462 </div>
1463 </div>
1464
1465 <div class="hgroup">
1466 <div class="hgroup-inline">
1467 <div class="panel">
1468 <h4 id="parseJson">
1469 std.parseJson(str)
1470 </h4>
1471 </div>
1472 <div style="clear: both"></div>
1473 </div>
1474 </div>
1475 <div class="hgroup">
1476 <div class="hgroup-inline">
1477 <div class="panel">
1478 <p>
1479 <em>
1480 Available since version 0.13.0.
1481 </em>
1482 </p>
1483 <p>
1484 Parses a JSON string.
1485 </p>
1486 <p>
1487 Example: <code>std.parseJson('{"foo": "bar"}')</code> yields <code>{ "foo": "bar" }</code>.
1488 </p>
1489 </div>
1490 <div style="clear: both"></div>
1491 </div>
1492 </div>
1493
1494 <div class="hgroup">
1495 <div class="hgroup-inline">
1496 <div class="panel">
1497 <h4 id="parseYaml">
1498 std.parseYaml(str)
1499 </h4>
1500 </div>
1501 <div style="clear: both"></div>
1502 </div>
1503 </div>
1504 <div class="hgroup">
1505 <div class="hgroup-inline">
1506 <div class="panel">
1507 <p>
1508 <em>
1509 Available since version 0.18.0.
1510 </em>
1511 </p>
1512 <p>
1513 Parses a YAML string. This is provided as a "best-effort" mechanism and should not be relied on to provide
1514 a fully standards compliant YAML parser. YAML is a superset of JSON, consequently "downcasting" or
1515 manifestation of YAML into JSON or Jsonnet values will only succeed when using the subset of YAML that is
1516 compatible with JSON. The parser does not support YAML documents with scalar values at the root. The
1517 root node of a YAML document must start with either a YAML sequence or map to be successfully parsed.
1518 </p>
1519 <p>
1520 Example: <code>std.parseYaml('foo: bar')</code> yields <code>{ "foo": "bar" }</code>.
1521 </p>
1522 </div>
1523 <div style="clear: both"></div>
1524 </div>
1525 </div>
1526
1527 <div class="hgroup">
1528 <div class="hgroup-inline">
1529 <div class="panel">
1530 <h4 id="encodeUTF8">
1531 std.encodeUTF8(str)
1532 </h4>
1533 </div>
1534 <div style="clear: both"></div>
1535 </div>
1536 </div>
1537 <div class="hgroup">
1538 <div class="hgroup-inline">
1539 <div class="panel">
1540 <p>
1541 <em>
1542 Available since version 0.13.0.
1543 </em>
1544 </p>
1545 <p>
1546 Encode a string using <a href="https://en.wikipedia.org/wiki/UTF-8">UTF8</a>. Returns an array of numbers
1547 representing bytes.
1548 </p>
1549
1550 </div>
1551 <div style="clear: both"></div>
1552 </div>
1553 </div>
1554
1555 <div class="hgroup">
1556 <div class="hgroup-inline">
1557 <div class="panel">
1558 <h4 id="decodeUTF8">
1559 std.decodeUTF8(arr)
1560 </h4>
1561 </div>
1562 <div style="clear: both"></div>
1563 </div>
1564 </div>
1565 <div class="hgroup">
1566 <div class="hgroup-inline">
1567 <div class="panel">
1568 <p>
1569 <em>
1570 Available since version 0.13.0.
1571 </em>
1572 </p>
1573 <p>
1574 Decode an array of numbers representing bytes using <a href="https://en.wikipedia.org/wiki/UTF-8">UTF8</a>.
1575 Returns a string.
1576 </p>
1577
1578 </div>
1579 <div style="clear: both"></div>
1580 </div>
1581 </div>
1582
1583
1584 <div class="hgroup">
1585 <div class="hgroup-inline">
1586 <div class="panel">
1587 <h3 id="manifestation">
1588 Manifestation
1589 </h3>
1590 </div>
1591 <div style="clear: both"></div>
1592 </div>
1593 </div>
1594
1595 <div class="hgroup">
1596 <div class="hgroup-inline">
1597 <div class="panel">
1598 <h4 id="manifestIni">
1599 std.manifestIni(ini)
1600 </h4>
1601 </div>
1602 <div style="clear: both"></div>
1603 </div>
1604 </div>
1605 <div class="hgroup">
1606 <div class="hgroup-inline">
1607 <div class="panel">
1608 <p>
1609 <em>
1610 Available since version 0.10.0.
1611 </em>
1612 </p>
1613 <p>
1614 Convert the given structure to a string in <a href="https://en.wikipedia.org/wiki/INI_file">INI format</a>. This
1615 allows using Jsonnet's
1616 object model to build a configuration to be consumed by an application expecting an INI
1617 file. The data is in the form of a set of sections, each containing a key/value mapping.
1618 These examples should make it clear:
1619 </p>
1620 <pre>{
1621 main: { a: "1", b: "2" },
1622 sections: {
1623 s1: {x: "11", y: "22", z: "33"},
1624 s2: {p: "yes", q: ""},
1625 empty: {},
1626 }
1627 }</pre>
1628 <p>
1629 Yields a string containing this INI file:
1630 </p>
1631 <pre>a = 1
1632 b = 2
1633 [empty]
1634 [s1]
1635 x = 11
1636 y = 22
1637 z = 33
1638 [s2]
1639 p = yes
1640 q =</pre>
1641
1642 </div>
1643 <div style="clear: both"></div>
1644 </div>
1645 </div>
1646
1647 <div class="hgroup">
1648 <div class="hgroup-inline">
1649 <div class="panel">
1650 <h4 id="manifestPython">
1651 std.manifestPython(v)
1652 </h4>
1653 </div>
1654 <div style="clear: both"></div>
1655 </div>
1656 </div>
1657 <div class="hgroup">
1658 <div class="hgroup-inline">
1659 <div class="panel">
1660 <p>
1661 <em>
1662 Available since version 0.10.0.
1663 </em>
1664 </p>
1665 <p>
1666 Convert the given value to a JSON-like form that is compatible with Python. The chief
1667 differences are True / False / None instead of true / false / null.
1668 </p>
1669 <pre>{
1670 b: ["foo", "bar"],
1671 c: true,
1672 d: null,
1673 e: { f1: false, f2: 42 },
1674 }</pre>
1675 <p>
1676 Yields a string containing Python code like:
1677 </p>
1678 <pre>{
1679 "b": ["foo", "bar"],
1680 "c": True,
1681 "d": None,
1682 "e": {"f1": False, "f2": 42}
1683 }</pre>
1684
1685 </div>
1686 <div style="clear: both"></div>
1687 </div>
1688 </div>
1689
1690 <div class="hgroup">
1691 <div class="hgroup-inline">
1692 <div class="panel">
1693 <h4 id="manifestPythonVars">
1694 std.manifestPythonVars(conf)
1695 </h4>
1696 </div>
1697 <div style="clear: both"></div>
1698 </div>
1699 </div>
1700 <div class="hgroup">
1701 <div class="hgroup-inline">
1702 <div class="panel">
1703 <p>
1704 <em>
1705 Available since version 0.10.0.
1706 </em>
1707 </p>
1708 <p>
1709 Convert the given object to a JSON-like form that is compatible with Python. The key
1710 difference to <code>std.manifestPython</code> is that the top level is represented as a list
1711 of Python global variables.
1712 </p>
1713 <pre>{
1714 b: ["foo", "bar"],
1715 c: true,
1716 d: null,
1717 e: { f1: false, f2: 42 },
1718 }</pre>
1719 <p>
1720 Yields a string containing this Python code:
1721 </p>
1722 <pre>b = ["foo", "bar"]
1723 c = True
1724 d = None
1725 e = {"f1": False, "f2": 42}</pre>
1726
1727 </div>
1728 <div style="clear: both"></div>
1729 </div>
1730 </div>
1731
1732 <div class="hgroup">
1733 <div class="hgroup-inline">
1734 <div class="panel">
1735 <h4 id="manifestJsonEx">
1736 std.manifestJsonEx(value, indent, newline, key_val_sep)
1737 </h4>
1738 </div>
1739 <div style="clear: both"></div>
1740 </div>
1741 </div>
1742 <div class="hgroup">
1743 <div class="hgroup-inline">
1744 <div class="panel">
1745 <p>
1746 <em>
1747 Available since version 0.10.0.
1748 </em>
1749 </p>
1750 <p>
1751 Convert the given object to a JSON form. <code>indent</code> is a string containing
1752 one or more whitespaces that are used for indentation. <code>newline</code> is
1753 by default <code>\n</code> and is inserted where a newline would normally be used
1754 to break long lines. <code>key_val_sep</code> is used to separate the key and value
1755 of an object field:
1756 </p>
1757 <p>
1758 Example: <code>std.manifestJsonEx(
1759 {
1760 x: [1, 2, 3, true, false, null,
1761 "string\nstring"],
1762 y: { a: 1, b: 2, c: [1, 2] },
1763 }, " ")</code> yields <code>"{\n \"x\": [\n 1,\n 2,\n 3,\n true,\n false,\n null,\n \"string\\nstring\"\n ],\n \"y\": {\n \"a\": 1,\n \"b\": 2,\n \"c\": [\n 1,\n 2\n ]\n }\n}"</code>.
1764 </p>
1765 <p>
1766 Example: <code>std.manifestJsonEx(
1767 {
1768 x: [1, 2, "string\nstring"],
1769 y: { a: 1, b: [1, 2] },
1770 }, "", " ", " : ")</code> yields <code>"{ \"x\" : [ 1, 2, \"string\\nstring\" ], \"y\" : { \"a\" : 1, \"b\" : [ 1, 2 ] } }"</code>.
1771 </p>
1772 </div>
1773 <div style="clear: both"></div>
1774 </div>
1775 </div>
1776
1777 <div class="hgroup">
1778 <div class="hgroup-inline">
1779 <div class="panel">
1780 <h4 id="manifestJsonMinified">
1781 std.manifestJsonMinified(value)
1782 </h4>
1783 </div>
1784 <div style="clear: both"></div>
1785 </div>
1786 </div>
1787 <div class="hgroup">
1788 <div class="hgroup-inline">
1789 <div class="panel">
1790 <p>
1791 <em>
1792 Available since version 0.18.0.
1793 </em>
1794 </p>
1795 <p>
1796 Convert the given object to a minified JSON form. Under the covers,
1797 it calls <code>std.manifestJsonEx:')</code>:
1798 </p>
1799 <p>
1800 Example: <code>std.manifestJsonMinified(
1801 {
1802 x: [1, 2, 3, true, false, null,
1803 "string\nstring"],
1804 y: { a: 1, b: 2, c: [1, 2] },
1805 })</code> yields <code>"{\"x\":[1,2,3,true,false,null,\"string\\nstring\"],\"y\":{\"a\":1,\"b\":2,\"c\":[1,2]}}"</code>.
1806 </p>
1807 </div>
1808 <div style="clear: both"></div>
1809 </div>
1810 </div>
1811
1812 <div class="hgroup">
1813 <div class="hgroup-inline">
1814 <div class="panel">
1815 <h4 id="manifestYamlDoc">
1816 std.manifestYamlDoc(value, indent_array_in_object=false, quote_keys=true)
1817 </h4>
1818 </div>
1819 <div style="clear: both"></div>
1820 </div>
1821 </div>
1822 <div class="hgroup">
1823 <div class="hgroup-inline">
1824 <div class="panel">
1825 <p>
1826 <em>
1827 Available since version 0.10.0.
1828 </em>
1829 </p>
1830 <p>
1831 Convert the given value to a YAML form. Note that <code>std.manifestJson</code> could also
1832 be used for this purpose, because any JSON is also valid YAML. But this function will
1833 produce more canonical-looking YAML.
1834 </p>
1835 <pre>std.manifestYamlDoc(
1836 {
1837 x: [1, 2, 3, true, false, null,
1838 "string\nstring\n"],
1839 y: { a: 1, b: 2, c: [1, 2] },
1840 },
1841 indent_array_in_object=false)</pre>
1842 <p>
1843 Yields a string containing this YAML:
1844 </p>
1845 <pre>"x":
1846 - 1
1847 - 2
1848 - 3
1849 - true
1850 - false
1851 - null
1852 - |
1853 string
1854 string
1855 "y":
1856 "a": 1
1857 "b": 2
1858 "c":
1859 - 1
1860 - 2</pre>
1861 <p>
1862 The <code>indent_array_in_object</code> param adds additional indentation which some people
1863 may find easier to read.
1864 </p>
1865 <p>
1866 The <code>quote_keys</code> parameter controls whether YAML identifiers are always quoted
1867 or only when necessary.
1868 </p>
1869
1870 </div>
1871 <div style="clear: both"></div>
1872 </div>
1873 </div>
1874
1875 <div class="hgroup">
1876 <div class="hgroup-inline">
1877 <div class="panel">
1878 <h4 id="manifestYamlStream">
1879 std.manifestYamlStream(value, indent_array_in_object=false, c_document_end=false, quote_keys=true)
1880 </h4>
1881 </div>
1882 <div style="clear: both"></div>
1883 </div>
1884 </div>
1885 <div class="hgroup">
1886 <div class="hgroup-inline">
1887 <div class="panel">
1888 <p>
1889 <em>
1890 Available since version 0.10.0.
1891 </em>
1892 </p>
1893 <p>
1894 Given an array of values, emit a YAML "stream", which is a sequence of documents separated
1895 by <code>---</code> and ending with <code>...</code>.
1896 </p>
1897 <pre>std.manifestYamlStream(
1898 ['a', 1, []],
1899 indent_array_in_object=false,
1900 c_document_end=true)</pre>
1901 <p>
1902 Yields this string:
1903 </p>
1904 <pre>---
1905 "a"
1906 ---
1907 1
1908 ---
1909 []
1910 ...</pre>
1911 <p>
1912 The <code>indent_array_in_object</code> and <code>quote_keys</code> params are the
1913 same as in <code>manifestYamlDoc</code>.
1914 </p>
1915 <p>
1916 The <code>c_document_end</code> param adds the optional terminating <code>...</code>.
1917 </p>
1918
1919 </div>
1920 <div style="clear: both"></div>
1921 </div>
1922 </div>
1923
1924 <div class="hgroup">
1925 <div class="hgroup-inline">
1926 <div class="panel">
1927 <h4 id="manifestXmlJsonml">
1928 std.manifestXmlJsonml(value)
1929 </h4>
1930 </div>
1931 <div style="clear: both"></div>
1932 </div>
1933 </div>
1934 <div class="hgroup">
1935 <div class="hgroup-inline">
1936 <div class="panel">
1937 <p>
1938 <em>
1939 Available since version 0.10.0.
1940 </em>
1941 </p>
1942 <p>
1943 Convert the given <a href="http://www.jsonml.org/">JsonML</a>-encoded value to a string
1944 containing the XML.
1945 </p>
1946 <pre>std.manifestXmlJsonml([
1947 'svg', { height: 100, width: 100 },
1948 [
1949 'circle', {
1950 cx: 50, cy: 50, r: 40,
1951 stroke: 'black', 'stroke-width': 3,
1952 fill: 'red',
1953 }
1954 ],
1955 ])</pre>
1956 <p>
1957 Yields a string containing this XML (all on one line):
1958 </p>
1959 <pre>&lt;svg height="100" width="100"&gt;
1960 &lt;circle cx="50" cy="50" fill="red" r="40"
1961 stroke="black" stroke-width="3"&gt;&lt;/circle&gt;;
1962 &lt;/svg&gt;;</pre>
1963 <p>
1964 Which represents the following image:
1965 </p>
1966 <svg height="100" width="100">
1967 <circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" />
1968 Sorry, your browser does not support inline SVG.
1969 </svg>
1970 <p>
1971 JsonML is designed to preserve "mixed-mode content" (i.e., textual data outside of or next
1972 to elements). This includes the whitespace needed to avoid having all the XML on one line,
1973 which is meaningful in XML. In order to have whitespace in the XML output, it must be
1974 present in the JsonML input:
1975 </p>
1976 <pre>std.manifestXmlJsonml([
1977 'svg',
1978 { height: 100, width: 100 },
1979 '\n ',
1980 [
1981 'circle',
1982 {
1983 cx: 50, cy: 50, r: 40, stroke: 'black',
1984 'stroke-width': 3, fill: 'red',
1985 }
1986 ],
1987 '\n',
1988 ])</pre>
1989
1990 </div>
1991 <div style="clear: both"></div>
1992 </div>
1993 </div>
1994
1995 <div class="hgroup">
1996 <div class="hgroup-inline">
1997 <div class="panel">
1998 <h4 id="manifestTomlEx">
1999 std.manifestTomlEx(toml, indent)
2000 </h4>
2001 </div>
2002 <div style="clear: both"></div>
2003 </div>
2004 </div>
2005 <div class="hgroup">
2006 <div class="hgroup-inline">
2007 <div class="panel">
2008 <p>
2009 <em>
2010 Available since version 0.18.0.
2011 </em>
2012 </p>
2013 <p>
2014 Convert the given object to a TOML form. <code>indent</code> is a string containing
2015 one or more whitespaces that are used for indentation:
2016 </p>
2017 <p>
2018 Example: <code>std.manifestTomlEx({
2019 key1: "value",
2020 key2: 1,
2021 section: {
2022 a: 1,
2023 b: "str",
2024 c: false,
2025 d: [1, "s", [2, 3]],
2026 subsection: {
2027 k: "v",
2028 },
2029 },
2030 sectionArray: [
2031 { k: "v1", v: 123 },
2032 { k: "v2", c: "value2" },
2033 ],
2034 }, " ")</code> yields <code>"key1 = \"value\"\nkey2 = 1\n\n[section]\n a = 1\n b = \"str\"\n c = false\n d = [\n 1,\n \"s\",\n [ 2, 3 ]\n ]\n\n [section.subsection]\n k = \"v\"\n\n[[sectionArray]]\n k = \"v1\"\n v = 123\n\n[[sectionArray]]\n c = \"value2\"\n k = \"v2\""</code>.
2035 </p>
2036 </div>
2037 <div style="clear: both"></div>
2038 </div>
2039 </div>
2040
2041
2042 <div class="hgroup">
2043 <div class="hgroup-inline">
2044 <div class="panel">
2045 <h3 id="arrays">
2046 Arrays
2047 </h3>
2048 </div>
2049 <div style="clear: both"></div>
2050 </div>
2051 </div>
2052
2053 <div class="hgroup">
2054 <div class="hgroup-inline">
2055 <div class="panel">
2056 <h4 id="makeArray">
2057 std.makeArray(sz, func)
2058 </h4>
2059 </div>
2060 <div style="clear: both"></div>
2061 </div>
2062 </div>
2063 <div class="hgroup">
2064 <div class="hgroup-inline">
2065 <div class="panel">
2066 <p>
2067 <em>
2068 Available since version 0.10.0.
2069 </em>
2070 </p>
2071 <p>
2072 Create a new array of <code>sz</code> elements by calling <code>func(i)</code> to initialize
2073 each element. Func is expected to be a function that takes a single parameter, the index of
2074 the element it should initialize.
2075 </p>
2076 <p>
2077 Example: <code>std.makeArray(3,function(x) x * x)</code> yields <code>[ 0, 1, 4 ]</code>.
2078 </p>
2079 </div>
2080 <div style="clear: both"></div>
2081 </div>
2082 </div>
2083
2084 <div class="hgroup">
2085 <div class="hgroup-inline">
2086 <div class="panel">
2087 <h4 id="member">
2088 std.member(arr, x)
2089 </h4>
2090 </div>
2091 <div style="clear: both"></div>
2092 </div>
2093 </div>
2094 <div class="hgroup">
2095 <div class="hgroup-inline">
2096 <div class="panel">
2097 <p>
2098 <em>
2099 Available since version 0.15.0.
2100 </em>
2101 </p>
2102 <p>
2103 Returns whether <code>x</code> occurs in <code>arr</code>.
2104 Argument <code>arr</code> may be an array or a string.
2105 </p>
2106
2107 </div>
2108 <div style="clear: both"></div>
2109 </div>
2110 </div>
2111
2112 <div class="hgroup">
2113 <div class="hgroup-inline">
2114 <div class="panel">
2115 <h4 id="count">
2116 std.count(arr, x)
2117 </h4>
2118 </div>
2119 <div style="clear: both"></div>
2120 </div>
2121 </div>
2122 <div class="hgroup">
2123 <div class="hgroup-inline">
2124 <div class="panel">
2125 <p>
2126 <em>
2127 Available since version 0.10.0.
2128 </em>
2129 </p>
2130 <p>
2131 Return the number of times that <code>x</code> occurs in <code>arr</code>.
2132 </p>
2133
2134 </div>
2135 <div style="clear: both"></div>
2136 </div>
2137 </div>
2138
2139 <div class="hgroup">
2140 <div class="hgroup-inline">
2141 <div class="panel">
2142 <h4 id="find">
2143 std.find(value, arr)
2144 </h4>
2145 </div>
2146 <div style="clear: both"></div>
2147 </div>
2148 </div>
2149 <div class="hgroup">
2150 <div class="hgroup-inline">
2151 <div class="panel">
2152 <p>
2153 <em>
2154 Available since version 0.10.0.
2155 </em>
2156 </p>
2157 <p>
2158 Returns an array that contains the indexes of all occurrences of <code>value</code> in
2159 <code>arr</code>.
2160 </p>
2161
2162 </div>
2163 <div style="clear: both"></div>
2164 </div>
2165 </div>
2166
2167 <div class="hgroup">
2168 <div class="hgroup-inline">
2169 <div class="panel">
2170 <h4 id="map">
2171 std.map(func, arr)
2172 </h4>
2173 </div>
2174 <div style="clear: both"></div>
2175 </div>
2176 </div>
2177 <div class="hgroup">
2178 <div class="hgroup-inline">
2179 <div class="panel">
2180 <p>
2181 <em>
2182 Available since version 0.10.0.
2183 </em>
2184 </p>
2185 <p>
2186 Apply the given function to every element of the array to form a new array.
2187 </p>
2188
2189 </div>
2190 <div style="clear: both"></div>
2191 </div>
2192 </div>
2193
2194 <div class="hgroup">
2195 <div class="hgroup-inline">
2196 <div class="panel">
2197 <h4 id="mapWithIndex">
2198 std.mapWithIndex(func, arr)
2199 </h4>
2200 </div>
2201 <div style="clear: both"></div>
2202 </div>
2203 </div>
2204 <div class="hgroup">
2205 <div class="hgroup-inline">
2206 <div class="panel">
2207 <p>
2208 <em>
2209 Available since version 0.10.0.
2210 </em>
2211 </p>
2212 <p>
2213 Similar to <a href="#map">map</a> above, but it also passes to the function the element's
2214 index in the array. The function <code>func</code> is expected to take the index as the
2215 first parameter and the element as the second.
2216 </p>
2217
2218 </div>
2219 <div style="clear: both"></div>
2220 </div>
2221 </div>
2222
2223 <div class="hgroup">
2224 <div class="hgroup-inline">
2225 <div class="panel">
2226 <h4 id="filterMap">
2227 std.filterMap(filter_func, map_func, arr)
2228 </h4>
2229 </div>
2230 <div style="clear: both"></div>
2231 </div>
2232 </div>
2233 <div class="hgroup">
2234 <div class="hgroup-inline">
2235 <div class="panel">
2236 <p>
2237 <em>
2238 Available since version 0.10.0.
2239 </em>
2240 </p>
2241 <p>
2242 It first filters, then maps the given array, using the two functions provided.
2243 </p>
2244
2245 </div>
2246 <div style="clear: both"></div>
2247 </div>
2248 </div>
2249
2250 <div class="hgroup">
2251 <div class="hgroup-inline">
2252 <div class="panel">
2253 <h4 id="flatMap">
2254 std.flatMap(func, arr)
2255 </h4>
2256 </div>
2257 <div style="clear: both"></div>
2258 </div>
2259 </div>
2260 <div class="hgroup">
2261 <div class="hgroup-inline">
2262 <div class="panel">
2263 <p>
2264 <em>
2265 Available since version 0.10.0.
2266 </em>
2267 </p>
2268 <p>
2269 Apply the given function to every element of <code>arr</code> to form a new array then flatten the result.
2270 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.
2271 If <code>arr</code> is a string, function <code>func</code> must return an string.
2272 </p>
2273 <p>
2274 The <code>std.flatMap</code> function can be thought of as a generalized <code>std.map</code>,
2275 with each element mapped to 0, 1 or more elements.
2276 </p>
2277 <p>
2278 Example: <code>std.flatMap(function(x) [x, x], [1, 2, 3])</code> yields <code>[ 1, 1, 2, 2, 3, 3 ]</code>.
2279 </p>
2280 <p>
2281 Example: <code>std.flatMap(function(x) if x == 2 then [] else [x], [1, 2, 3])</code> yields <code>[ 1, 3 ]</code>.
2282 </p>
2283 <p>
2284 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>.
2285 </p>
2286 <p>
2287 Example: <code>std.flatMap(function(x) x+x, "foo")</code> yields <code>"ffoooo"</code>.
2288 </p>
2289 </div>
2290 <div style="clear: both"></div>
2291 </div>
2292 </div>
2293
2294 <div class="hgroup">
2295 <div class="hgroup-inline">
2296 <div class="panel">
2297 <h4 id="filter">
2298 std.filter(func, arr)
2299 </h4>
2300 </div>
2301 <div style="clear: both"></div>
2302 </div>
2303 </div>
2304 <div class="hgroup">
2305 <div class="hgroup-inline">
2306 <div class="panel">
2307 <p>
2308 <em>
2309 Available since version 0.10.0.
2310 </em>
2311 </p>
2312 <p>
2313 Return a new array containing all the elements of <code>arr</code> for which the
2314 <code>func</code> function returns true.
2315 </p>
2316
2317 </div>
2318 <div style="clear: both"></div>
2319 </div>
2320 </div>
2321
2322 <div class="hgroup">
2323 <div class="hgroup-inline">
2324 <div class="panel">
2325 <h4 id="foldl">
2326 std.foldl(func, arr, init)
2327 </h4>
2328 </div>
2329 <div style="clear: both"></div>
2330 </div>
2331 </div>
2332 <div class="hgroup">
2333 <div class="hgroup-inline">
2334 <div class="panel">
2335 <p>
2336 <em>
2337 Available since version 0.10.0.
2338 </em>
2339 </p>
2340 <p>
2341 Classic foldl function. Calls the function on the result of the previous function call and
2342 each array element, or <code>init</code> in the case of the initial element. Traverses the
2343 array from left to right.
2344 </p>
2345
2346 </div>
2347 <div style="clear: both"></div>
2348 </div>
2349 </div>
2350
2351 <div class="hgroup">
2352 <div class="hgroup-inline">
2353 <div class="panel">
2354 <h4 id="foldr">
2355 std.foldr(func, arr, init)
2356 </h4>
2357 </div>
2358 <div style="clear: both"></div>
2359 </div>
2360 </div>
2361 <div class="hgroup">
2362 <div class="hgroup-inline">
2363 <div class="panel">
2364 <p>
2365 <em>
2366 Available since version 0.10.0.
2367 </em>
2368 </p>
2369 <p>
2370 Classic foldr function. Calls the function on the result of the previous function call and
2371 each array element, or <code>init</code> in the case of the initial element. Traverses the
2372 array from right to left.
2373 </p>
2374
2375 </div>
2376 <div style="clear: both"></div>
2377 </div>
2378 </div>
2379
2380 <div class="hgroup">
2381 <div class="hgroup-inline">
2382 <div class="panel">
2383 <h4 id="range">
2384 std.range(from, to)
2385 </h4>
2386 </div>
2387 <div style="clear: both"></div>
2388 </div>
2389 </div>
2390 <div class="hgroup">
2391 <div class="hgroup-inline">
2392 <div class="panel">
2393 <p>
2394 <em>
2395 Available since version 0.10.0.
2396 </em>
2397 </p>
2398 <p>
2399 Return an array of ascending numbers between the two limits, inclusively.
2400 </p>
2401
2402 </div>
2403 <div style="clear: both"></div>
2404 </div>
2405 </div>
2406
2407 <div class="hgroup">
2408 <div class="hgroup-inline">
2409 <div class="panel">
2410 <h4 id="repeat">
2411 std.repeat(what, count)
2412 </h4>
2413 </div>
2414 <div style="clear: both"></div>
2415 </div>
2416 </div>
2417 <div class="hgroup">
2418 <div class="hgroup-inline">
2419 <div class="panel">
2420 <p>
2421 <em>
2422 Available since version 0.15.0.
2423 </em>
2424 </p>
2425 <p>
2426 Repeats an array or a string <code>what</code> a number of times specified by an integer <code>count</code>.
2427 </p>
2428 <p>
2429 Example: <code>std.repeat([1, 2, 3], 3)</code> yields <code>[ 1, 2, 3, 1, 2, 3, 1, 2, 3 ]</code>.
2430 </p>
2431 <p>
2432 Example: <code>std.repeat("blah", 2)</code> yields <code>"blahblah"</code>.
2433 </p>
2434 </div>
2435 <div style="clear: both"></div>
2436 </div>
2437 </div>
2438
2439 <div class="hgroup">
2440 <div class="hgroup-inline">
2441 <div class="panel">
2442 <h4 id="slice">
2443 std.slice(indexable, index, end, step)
2444 </h4>
2445 </div>
2446 <div style="clear: both"></div>
2447 </div>
2448 </div>
2449 <div class="hgroup">
2450 <div class="hgroup-inline">
2451 <div class="panel">
2452 <p>
2453 <em>
2454 Available since version 0.10.0.
2455 </em>
2456 </p>
2457 <p>
2458 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.
2459 </p>
2460 <p>
2461 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>).
2462 </p>
2463 <p>
2464 Example: <code>std.slice([1, 2, 3, 4, 5, 6], 0, 4, 1)</code> yields <code>[ 1, 2, 3, 4 ]</code>.
2465 </p>
2466 <p>
2467 Example: <code>std.slice([1, 2, 3, 4, 5, 6], 1, 6, 2)</code> yields <code>[ 2, 4, 6 ]</code>.
2468 </p>
2469 <p>
2470 Example: <code>std.slice("jsonnet", 0, 4, 1)</code> yields <code>"json"</code>.
2471 </p>
2472 </div>
2473 <div style="clear: both"></div>
2474 </div>
2475 </div>
2476
2477 <div class="hgroup">
2478 <div class="hgroup-inline">
2479 <div class="panel">
2480 <h4 id="join">
2481 std.join(sep, arr)
2482 </h4>
2483 </div>
2484 <div style="clear: both"></div>
2485 </div>
2486 </div>
2487 <div class="hgroup">
2488 <div class="hgroup-inline">
2489 <div class="panel">
2490 <p>
2491 <em>
2492 Available since version 0.10.0.
2493 </em>
2494 </p>
2495 <p>
2496 If <code>sep</code> is a string, then <code>arr</code> must be an array of strings, in which
2497 case they are concatenated with <code>sep</code> used as a delimiter. If <code>sep</code>
2498 is an array, then <code>arr</code> must be an array of arrays, in which case the arrays are
2499 concatenated in the same way, to produce a single array.
2500 </p>
2501 <p>
2502 Example: <code>std.join(".", ["www", "google", "com"])</code> yields <code>"www.google.com"</code>.
2503 </p>
2504 <p>
2505 Example: <code>std.join([9, 9], [[1], [2, 3]])</code> yields <code>[ 1, 9, 9, 2, 3 ]</code>.
2506 </p>
2507 </div>
2508 <div style="clear: both"></div>
2509 </div>
2510 </div>
2511
2512 <div class="hgroup">
2513 <div class="hgroup-inline">
2514 <div class="panel">
2515 <h4 id="lines">
2516 std.lines(arr)
2517 </h4>
2518 </div>
2519 <div style="clear: both"></div>
2520 </div>
2521 </div>
2522 <div class="hgroup">
2523 <div class="hgroup-inline">
2524 <div class="panel">
2525 <p>
2526 <em>
2527 Available since version 0.10.0.
2528 </em>
2529 </p>
2530 <p>
2531 Concatenate an array of strings into a text file with newline characters after each string.
2532 This is suitable for constructing bash scripts and the like.
2533 </p>
2534
2535 </div>
2536 <div style="clear: both"></div>
2537 </div>
2538 </div>
2539
2540 <div class="hgroup">
2541 <div class="hgroup-inline">
2542 <div class="panel">
2543 <h4 id="flattenArrays">
2544 std.flattenArrays(arr)
2545 </h4>
2546 </div>
2547 <div style="clear: both"></div>
2548 </div>
2549 </div>
2550 <div class="hgroup">
2551 <div class="hgroup-inline">
2552 <div class="panel">
2553 <p>
2554 <em>
2555 Available since version 0.10.0.
2556 </em>
2557 </p>
2558 <p>
2559 Concatenate an array of arrays into a single array.
2560 </p>
2561 <p>
2562 Example: <code>std.flattenArrays([[1, 2], [3, 4], [[5, 6], [7, 8]]])</code> yields <code>[ 1, 2, 3, 4, [ 5, 6 ], [ 7, 8 ] ]</code>.
2563 </p>
2564 </div>
2565 <div style="clear: both"></div>
2566 </div>
2567 </div>
2568
2569 <div class="hgroup">
2570 <div class="hgroup-inline">
2571 <div class="panel">
2572 <h4 id="reverse">
2573 std.reverse(arrs)
2574 </h4>
2575 </div>
2576 <div style="clear: both"></div>
2577 </div>
2578 </div>
2579 <div class="hgroup">
2580 <div class="hgroup-inline">
2581 <div class="panel">
2582 <p>
2583 <em>
2584 Available since version 0.13.0.
2585 </em>
2586 </p>
2587 <p>
2588 Reverses an array.
2589 </p>
2590
2591 </div>
2592 <div style="clear: both"></div>
2593 </div>
2594 </div>
2595
2596 <div class="hgroup">
2597 <div class="hgroup-inline">
2598 <div class="panel">
2599 <h4 id="sort">
2600 std.sort(arr, keyF=id)
2601 </h4>
2602 </div>
2603 <div style="clear: both"></div>
2604 </div>
2605 </div>
2606 <div class="hgroup">
2607 <div class="hgroup-inline">
2608 <div class="panel">
2609 <p>
2610 <em>
2611 Available since version 0.10.0.
2612 </em>
2613 </p>
2614 <p>
2615 Sorts the array using the <= operator.
2616 </p>
2617 <p>
2618 Optional argument <code>keyF</code> is a single argument function used to extract comparison key from each array element.
2619 Default value is identity function <code>keyF=function(x) x</code>.
2620 </p>
2621
2622 </div>
2623 <div style="clear: both"></div>
2624 </div>
2625 </div>
2626
2627 <div class="hgroup">
2628 <div class="hgroup-inline">
2629 <div class="panel">
2630 <h4 id="uniq">
2631 std.uniq(arr, keyF=id)
2632 </h4>
2633 </div>
2634 <div style="clear: both"></div>
2635 </div>
2636 </div>
2637 <div class="hgroup">
2638 <div class="hgroup-inline">
2639 <div class="panel">
2640 <p>
2641 <em>
2642 Available since version 0.10.0.
2643 </em>
2644 </p>
2645 <p>
2646 Removes successive duplicates. When given a sorted array, removes all duplicates.
2647 </p>
2648 <p>
2649 Optional argument <code>keyF</code> is a single argument function used to extract comparison key from each array element.
2650 Default value is identity function <code>keyF=function(x) x</code>.
2651 </p>
2652
2653 </div>
2654 <div style="clear: both"></div>
2655 </div>
2656 </div>
2657
2658 <div class="hgroup">
2659 <div class="hgroup-inline">
2660 <div class="panel">
2661 <h4 id="all">
2662 std.all(arr)
2663 </h4>
2664 </div>
2665 <div style="clear: both"></div>
2666 </div>
2667 </div>
2668 <div class="hgroup">
2669 <div class="hgroup-inline">
2670 <div class="panel">
2671 <p>
2672 <em>
2673 Available since version 0.19.0.
2674 </em>
2675 </p>
2676 <p>
2677 Return true if all elements of <code>arr</code> is true, false otherwise. <code>all([])</code> evaluates to true.
2678 </p>
2679 <p>
2680 It's an error if 1) <code>arr</code> is not an array, or 2) <code>arr</code> contains non-boolean values.
2681 </p>
2682
2683 </div>
2684 <div style="clear: both"></div>
2685 </div>
2686 </div>
2687
2688 <div class="hgroup">
2689 <div class="hgroup-inline">
2690 <div class="panel">
2691 <h4 id="any">
2692 std.any(arr)
2693 </h4>
2694 </div>
2695 <div style="clear: both"></div>
2696 </div>
2697 </div>
2698 <div class="hgroup">
2699 <div class="hgroup-inline">
2700 <div class="panel">
2701 <p>
2702 <em>
2703 Available since version 0.19.0.
2704 </em>
2705 </p>
2706 <p>
2707 Return true if any element of <code>arr</code> is true, false otherwise. <code>any([])</code> evaluates to false.
2708 </p>
2709 <p>
2710 It's an error if 1) <code>arr</code> is not an array, or 2) <code>arr</code> contains non-boolean values.
2711 </p>
2712
2713 </div>
2714 <div style="clear: both"></div>
2715 </div>
2716 </div>
2717
2718 <div class="hgroup">
2719 <div class="hgroup-inline">
2720 <div class="panel">
2721 <h4 id="sum">
2722 std.sum(arr)
2723 </h4>
2724 </div>
2725 <div style="clear: both"></div>
2726 </div>
2727 </div>
2728 <div class="hgroup">
2729 <div class="hgroup-inline">
2730 <div class="panel">
2731 <p>
2732 <em>
2733 Available in upcoming release.
2734 </em>
2735 </p>
2736 <p>
2737 Return sum of all element in <code>arr</code>.
2738 </p>
2739
2740 </div>
2741 <div style="clear: both"></div>
2742 </div>
2743 </div>
2744
2745
2746 <div class="hgroup">
2747 <div class="hgroup-inline">
2748 <div class="panel">
2749 <h3 id="sets">
2750 Sets
2751 </h3>
2752 </div>
2753 <div style="clear: both"></div>
2754 </div>
2755 </div>
2756 <div class="hgroup">
2757 <div class="hgroup-inline">
2758 <div class="panel">
2759 <p>
2760 Sets are represented as ordered arrays without duplicates.
2761 </p>
2762 <p>
2763 Note that the <code>std.set*</code> functions rely on the uniqueness and ordering
2764 on arrays passed to them to work. This can be guaranteed by using <code>std.set(arr)</code>.
2765 If that is not the case, the functions will quietly return non-meaningful results.
2766 </p>
2767 <p>
2768 All <code>set.set*</code> functions accept <code>keyF</code> function of one argument, which can be
2769 used to extract key to use from each element. All Set operations then use extracted key for the purpose
2770 of identifying uniqueness. Default value is identity function <code>local id = function(x) x</code>.
2771 </p>
2772 </div>
2773 <div style="clear: both"></div>
2774 </div>
2775 </div>
2776
2777 <div class="hgroup">
2778 <div class="hgroup-inline">
2779 <div class="panel">
2780 <h4 id="set">
2781 std.set(arr, keyF=id)
2782 </h4>
2783 </div>
2784 <div style="clear: both"></div>
2785 </div>
2786 </div>
2787 <div class="hgroup">
2788 <div class="hgroup-inline">
2789 <div class="panel">
2790 <p>
2791 <em>
2792 Available since version 0.10.0.
2793 </em>
2794 </p>
2795 <p>
2796 Shortcut for std.uniq(std.sort(arr)).
2797 </p>
2798
2799 </div>
2800 <div style="clear: both"></div>
2801 </div>
2802 </div>
2803
2804 <div class="hgroup">
2805 <div class="hgroup-inline">
2806 <div class="panel">
2807 <h4 id="setInter">
2808 std.setInter(a, b, keyF=id)
2809 </h4>
2810 </div>
2811 <div style="clear: both"></div>
2812 </div>
2813 </div>
2814 <div class="hgroup">
2815 <div class="hgroup-inline">
2816 <div class="panel">
2817 <p>
2818 <em>
2819 Available since version 0.10.0.
2820 </em>
2821 </p>
2822 <p>
2823 Set intersection operation (values in both a and b).
2824 </p>
2825
2826 </div>
2827 <div style="clear: both"></div>
2828 </div>
2829 </div>
2830
2831 <div class="hgroup">
2832 <div class="hgroup-inline">
2833 <div class="panel">
2834 <h4 id="setUnion">
2835 std.setUnion(a, b, keyF=id)
2836 </h4>
2837 </div>
2838 <div style="clear: both"></div>
2839 </div>
2840 </div>
2841 <div class="hgroup">
2842 <div class="hgroup-inline">
2843 <div class="panel">
2844 <p>
2845 <em>
2846 Available since version 0.10.0.
2847 </em>
2848 </p>
2849 <p>
2850 Set union operation (values in any of <code>a</code> or <code>b</code>). Note that + on sets will simply
2851 concatenate
2852 the arrays, possibly forming an array that is not a set (due to not being ordered without
2853 duplicates).
2854 </p>
2855 <p>
2856 Example: <code>std.setUnion([1, 2], [2, 3])</code> yields <code>[ 1, 2, 3 ]</code>.
2857 </p>
2858 <p>
2859 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>.
2860 </p>
2861 </div>
2862 <div style="clear: both"></div>
2863 </div>
2864 </div>
2865
2866 <div class="hgroup">
2867 <div class="hgroup-inline">
2868 <div class="panel">
2869 <h4 id="setDiff">
2870 std.setDiff(a, b, keyF=id)
2871 </h4>
2872 </div>
2873 <div style="clear: both"></div>
2874 </div>
2875 </div>
2876 <div class="hgroup">
2877 <div class="hgroup-inline">
2878 <div class="panel">
2879 <p>
2880 <em>
2881 Available since version 0.10.0.
2882 </em>
2883 </p>
2884 <p>
2885 Set difference operation (values in a but not b).
2886 </p>
2887
2888 </div>
2889 <div style="clear: both"></div>
2890 </div>
2891 </div>
2892
2893 <div class="hgroup">
2894 <div class="hgroup-inline">
2895 <div class="panel">
2896 <h4 id="setMember">
2897 std.setMember(x, arr, keyF=id)
2898 </h4>
2899 </div>
2900 <div style="clear: both"></div>
2901 </div>
2902 </div>
2903 <div class="hgroup">
2904 <div class="hgroup-inline">
2905 <div class="panel">
2906 <p>
2907 <em>
2908 Available since version 0.10.0.
2909 </em>
2910 </p>
2911 <p>
2912 Returns <code>true</code> if x is a member of array, otherwise <code>false</code>.
2913 </p>
2914
2915 </div>
2916 <div style="clear: both"></div>
2917 </div>
2918 </div>
2919
2920
2921 <div class="hgroup">
2922 <div class="hgroup-inline">
2923 <div class="panel">
2924 <h3 id="encoding">
2925 Encoding
2926 </h3>
2927 </div>
2928 <div style="clear: both"></div>
2929 </div>
2930 </div>
2931
2932 <div class="hgroup">
2933 <div class="hgroup-inline">
2934 <div class="panel">
2935 <h4 id="base64">
2936 std.base64(input)
2937 </h4>
2938 </div>
2939 <div style="clear: both"></div>
2940 </div>
2941 </div>
2942 <div class="hgroup">
2943 <div class="hgroup-inline">
2944 <div class="panel">
2945 <p>
2946 <em>
2947 Available since version 0.10.0.
2948 </em>
2949 </p>
2950 <p>
2951 Encodes the given value into a base64 string. The encoding sequence is <code>A-Za-z0-9+/</code> with
2952 <code>=</code>
2953 to pad the output to a multiple of 4 characters. The value can be a string or an array of
2954 numbers, but the codepoints / numbers must be in the 0 to 255 range. The resulting string
2955 has no line breaks.
2956 </p>
2957
2958 </div>
2959 <div style="clear: both"></div>
2960 </div>
2961 </div>
2962
2963 <div class="hgroup">
2964 <div class="hgroup-inline">
2965 <div class="panel">
2966 <h4 id="base64DecodeBytes">
2967 std.base64DecodeBytes(str)
2968 </h4>
2969 </div>
2970 <div style="clear: both"></div>
2971 </div>
2972 </div>
2973 <div class="hgroup">
2974 <div class="hgroup-inline">
2975 <div class="panel">
2976 <p>
2977 <em>
2978 Available since version 0.10.0.
2979 </em>
2980 </p>
2981 <p>
2982 Decodes the given base64 string into an array of bytes (number values). Currently assumes
2983 the input string has no linebreaks and is padded to a multiple of 4 (with the = character).
2984 In other words, it consumes the output of std.base64().
2985 </p>
2986
2987 </div>
2988 <div style="clear: both"></div>
2989 </div>
2990 </div>
2991
2992 <div class="hgroup">
2993 <div class="hgroup-inline">
2994 <div class="panel">
2995 <h4 id="base64Decode">
2996 std.base64Decode(str)
2997 </h4>
2998 </div>
2999 <div style="clear: both"></div>
3000 </div>
3001 </div>
3002 <div class="hgroup">
3003 <div class="hgroup-inline">
3004 <div class="panel">
3005 <p>
3006 <em>
3007 Available since version 0.10.0.
3008 </em>
3009 </p>
3010 <p>
3011 <em>Deprecated, use <code>std.base64DecodeBytes</code> and decode the string explicitly (e.g. with <code>std.decodeUTF8</code>) instead.</code></em>
3012 </p>
3013 <p>
3014 Behaves like std.base64DecodeBytes() except returns a naively encoded string instead of an array of bytes.
3015 </p>
3016
3017 </div>
3018 <div style="clear: both"></div>
3019 </div>
3020 </div>
3021
3022 <div class="hgroup">
3023 <div class="hgroup-inline">
3024 <div class="panel">
3025 <h4 id="md5">
3026 std.md5(s)
3027 </h4>
3028 </div>
3029 <div style="clear: both"></div>
3030 </div>
3031 </div>
3032 <div class="hgroup">
3033 <div class="hgroup-inline">
3034 <div class="panel">
3035 <p>
3036 <em>
3037 Available since version 0.10.0.
3038 </em>
3039 </p>
3040 <p>
3041 Encodes the given value into an MD5 string.
3042 </p>
3043
3044 </div>
3045 <div style="clear: both"></div>
3046 </div>
3047 </div>
3048
3049
3050 <div class="hgroup">
3051 <div class="hgroup-inline">
3052 <div class="panel">
3053 <h3 id="booleans">
3054 Booleans
3055 </h3>
3056 </div>
3057 <div style="clear: both"></div>
3058 </div>
3059 </div>
3060
3061 <div class="hgroup">
3062 <div class="hgroup-inline">
3063 <div class="panel">
3064 <h4 id="xor">
3065 std.xor(x, y)
3066 </h4>
3067 </div>
3068 <div style="clear: both"></div>
3069 </div>
3070 </div>
3071 <div class="hgroup">
3072 <div class="hgroup-inline">
3073 <div class="panel">
3074 <p>
3075 <em>
3076 Available in upcoming release.
3077 </em>
3078 </p>
3079 <p>
3080 Returns the xor of the two given booleans.
3081 </p>
3082
3083 </div>
3084 <div style="clear: both"></div>
3085 </div>
3086 </div>
3087
3088 <div class="hgroup">
3089 <div class="hgroup-inline">
3090 <div class="panel">
3091 <h4 id="xnor">
3092 std.xnor(x, y)
3093 </h4>
3094 </div>
3095 <div style="clear: both"></div>
3096 </div>
3097 </div>
3098 <div class="hgroup">
3099 <div class="hgroup-inline">
3100 <div class="panel">
3101 <p>
3102 <em>
3103 Available in upcoming release.
3104 </em>
3105 </p>
3106 <p>
3107 Returns the xnor of the two given booleans.
3108 </p>
3109
3110 </div>
3111 <div style="clear: both"></div>
3112 </div>
3113 </div>
3114
3115
3116 <div class="hgroup">
3117 <div class="hgroup-inline">
3118 <div class="panel">
3119 <h3 id="json_merge_patch">
3120 JSON Merge Patch
3121 </h3>
3122 </div>
3123 <div style="clear: both"></div>
3124 </div>
3125 </div>
3126
3127 <div class="hgroup">
3128 <div class="hgroup-inline">
3129 <div class="panel">
3130 <h4 id="mergePatch">
3131 std.mergePatch(target, patch)
3132 </h4>
3133 </div>
3134 <div style="clear: both"></div>
3135 </div>
3136 </div>
3137 <div class="hgroup">
3138 <div class="hgroup-inline">
3139 <div class="panel">
3140 <p>
3141 <em>
3142 Available since version 0.10.0.
3143 </em>
3144 </p>
3145 <p>
3146 Applies <code>patch</code> to <code>target</code>
3147 according to <a href="https://tools.ietf.org/html/rfc7396">RFC7396</a>
3148 </p>
3149
3150 </div>
3151 <div style="clear: both"></div>
3152 </div>
3153 </div>
3154
3155
3156 <div class="hgroup">
3157 <div class="hgroup-inline">
3158 <div class="panel">
3159 <h3 id="debugging">
3160 Debugging
3161 </h3>
3162 </div>
3163 <div style="clear: both"></div>
3164 </div>
3165 </div>
3166
3167 <div class="hgroup">
3168 <div class="hgroup-inline">
3169 <div class="panel">
3170 <h4 id="trace">
3171 std.trace(str, rest)
3172 </h4>
3173 </div>
3174 <div style="clear: both"></div>
3175 </div>
3176 </div>
3177 <div class="hgroup">
3178 <div class="hgroup-inline">
3179 <div class="panel">
3180 <p>
3181 <em>
3182 Available since version 0.11.0.
3183 </em>
3184 </p>
3185 <p>
3186 Outputs the given string <code>str</code> to stderr and
3187 returns <code>rest</code> as the result.
3188 </p>
3189 <p>
3190 Example:
3191 </p>
3192 <p>
3193 <pre>local conditionalReturn(cond, in1, in2) =
3194 if (cond) then
3195 std.trace('cond is true returning '
3196 + std.toString(in1), in1)
3197 else
3198 std.trace('cond is false returning '
3199 + std.toString(in2), in2);
3200
3201 {
3202 a: conditionalReturn(true, { b: true }, { c: false }),
3203 }</pre>
3204 </p>
3205 <p>
3206 Prints:
3207 </p>
3208 <p>
3209 <pre>TRACE: test.jsonnet:3 cond is true returning {"b": true}
3210 {
3211 "a": {
3212 "b": true
3213 }
3214 }</pre>
3215 </p>
3216
3217 </div>
3218 <div style="clear: both"></div>
3219 </div>
3220 </div>
3221
3222