Returns true if some element of the list matches the condition. It stops the iterations after the first match.

Functions

countBy

countBy(Array<T>, (T) → Boolean): Number

Counts the matching elements using a matchingFunction(T)

Transform
1
2
3
4
%dw 2.0
output application/json
---
[1, 2, 3] countBy (($ mod 2) == 0)
Output
1
1

divideBy

divideBy(Array<T>, Number): Array<Array<T>>

Divides an Array of items into sub arrays. .Transform

1
2
3
output application/json
---
[1, 2, 3, 4, 5] divideBy 2
Output
1
2
3
4
5
6
7
8
9
10
[
   [
     1,
     2
   ],
   [
     4,
     5
   ]
 ]

every

every(Array<T>, (T) → Boolean): Boolean

Returns true if every element of the list matches the condition. It stops the iterations after the first negative evaluation.

some

some(Array<T>, (T) → Boolean): Boolean

sumBy

sumBy(Array<T>, (T) → Number): Number

Adds the values returned by the right hand side function

Transform
1
2
3
4
5
%dw 2.0
output application/json
---
sumBy([ { a: 1 }, { a: 2 }, { a: 3 } ], (item) -> item.a)
// same as [ { a: 1 }, { a: 2 }, { a: 3 } ] sumBy $.a
Output
1
6