Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Use only value-key order where applicable

...

Note: in addition to these operators, there is a membership infix operator that works on arrays and maps

Table of Contents

Info
titleEngine Compatibility

Functions which expected a key and then a value in classic KRL now expect a value and then a key in the Node Pico Engine. This applies to the filter() and map() operators.

Hash Paths

Many of the following operators take an argument that is a hash path. A hash path is an array whose elements represent the key values (for a map) or array indices of a path from the root of a complex data structure to the element of interest. For example, consider the following data structure:

...

Code Block
languagejavascript
themeConfluence
a = {"a": 3, "b": 4, "c": 5};
c = a.filter(function(v,k,v){v < 5})    // c = {"a": 3, "b": 4}
d = a.filter(function(v,k,v){k eq "a"}) // d = {"a": 3}

...

The map() operator returns a map that contains the results of applying the function given as the operator's argument to each key-value pair from the original map. The function given as an argument must take two arguments: the first will be the key value and the second the valuekey. The result will be a map with the same keys, each key mapped to the result of the function. The length of the resulting map will be equal to the length of the target map. For example:

Code Block
languagejavascript
themeConfluence
a = {"a": 3, "b": 4, "c": 5};
c = a.map(function(v,k,v) {v+2}) // c = {"a": 5, "b": 6, "c": 7}

...