-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharrays.libsonnet
43 lines (33 loc) · 1.11 KB
/
arrays.libsonnet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
local d = import "doc-util/main.libsonnet";
{
arrays: {
'#all': d.fn(
|||
`all` passes each element of the collection to the given function.
`all` returns true if the function provided never returns false.
> `PARAMETERS`
* `fn (function(x) bool)` - where `x` is a value from the array; and a boolean is returned
* `o (object)` - the object to evaluate
> `RETURNS`
`bool`
|||,
[d.arg('fn', d.T.func), d.arg('arr', d.T.array)]),
all(fn, arr):: (
std.length(std.filter(fn, arr)) == std.length(arr)
),
'#any': d.fn(
|||
`any` passes each element of the collection to the given function.
`any` returns true if the function provided ever returns true.
> `PARAMETERS`
* `fn (function(x) bool)` - where `x` is a value from the array; and a boolean is returned
* `o (object)` - the object to evaluate
> `RETURNS`
`bool`
|||,
[d.arg('fn', d.T.func), d.arg('arr', d.T.array)]),
any(fn, arr):: (
std.length(std.filter(fn, arr)) == std.length(arr)
),
},
}