Higher Order Operators

Higher order operations are significantly more complex than the other types of operations, because they allow you to apply a piece of logic iteratively.

OperatorsInstruction
Mapmap
Reducereduce
FilterFilter
Everyevery, all
Somesome
Nonenone
Each Object KeyeachKey
Additionally, it is important to note that this module supports handlebars style traversal of data within these control structures.

Map

The first operand defines the array you are operating on, while the second defines the operation you are performing. The context switches such that the local variable is the value from the array.

This following example shows the Handlebars style traversal -

Reduce

The first operand defines the array you are operating on, while the second defines the operation you are performing. The context switches such that the value "current" is the value from the array, and "accumulator" is the accumulated value.
The third operand can be excluded.

Filter

Every, All

Some

None

Each Key

Sometimes you may wish to iterate over an object instead of an array, executing the logic on each value in the object. json-logic-engine has a built in operator for this: