@@ -83,6 +83,7 @@ local html = import 'html.libsonnet';
83
83
{
84
84
name: 'objectValues' ,
85
85
params: ['o' ],
86
+ availableSince: '0.17.0' ,
86
87
description: |||
87
88
Returns an array of the values in the given object. Does not include hidden fields.
88
89
||| ,
@@ -104,6 +105,7 @@ local html = import 'html.libsonnet';
104
105
{
105
106
name: 'objectValuesAll' ,
106
107
params: ['o' ],
108
+ availableSince: '0.17.0' ,
107
109
description: |||
108
110
As <code>std.objectValues</code> but also includes hidden fields.
109
111
||| ,
@@ -944,10 +946,17 @@ local html = import 'html.libsonnet';
944
946
{
945
947
name: 'flatMap' ,
946
948
params: ['func' , 'arr' ],
947
- description: |||
948
- Apply the given function to every element of the array to form a new array then flatten the result.
949
- It can be thought of as a generalized map, where each element can get mapped to 0, 1 or more elements.
950
- ||| ,
949
+ description: html.paragraphs([
950
+ |||
951
+ Apply the given function to every element of <code>arr</code> to form a new array then flatten the result.
952
+ 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.
953
+ If <code>arr</code> is a string, function <code>func</code> must return an string.
954
+ ||| ,
955
+ |||
956
+ The <code>std.flatMap</code> function can be thought of as a generalized <code>std.map</code>,
957
+ with each element mapped to 0, 1 or more elements.
958
+ |||
959
+ ]),
951
960
examples: [
952
961
{
953
962
input: 'std.flatMap(function(x) [x, x], [1, 2, 3])' ,
@@ -961,6 +970,10 @@ local html = import 'html.libsonnet';
961
970
input: 'std.flatMap(function(x) if x == 2 then [] else [x * 3, x * 2], [1, 2, 3])' ,
962
971
output: std.flatMap(function (x) if x == 2 then [] else [x * 3 , x * 2 ], [1 , 2 , 3 ]),
963
972
},
973
+ {
974
+ input: 'std.flatMap(function(x) x+x, "foo")' ,
975
+ output: std.flatMap(function (x) x+x, "foo" )
976
+ },
964
977
],
965
978
},
966
979
{
0 commit comments