Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Table of Contents
maxLevel2
excludeAdditional Resources|Related Links|Related Information

sl.ensureArray

DescriptionTakes an argument and returns that argument unchanged if it is an array, otherwise it should return the argument in an array.
Syntax


Code Block
sl.ensureArray(arg)


Example

Expression: sl.ensureArray([1,2,3])

Result: [1,2,3]


sl.gethostbyname

DescriptionReturns an array of IPv4 or IPv6 addresses for the given hostname or IP address.
Syntax


Code Block
sl.gethostbyname(host)


Example

Expression: sl.gethostbyname("www.snaplogic.com")

Result:

Code Block
[
      {
        "address": "54.214.241.155",
        "family": "ipv4",
        "hostname": "www.snaplogic.com"
      }
    ]


sl.range

Description

This function returns an array of numbers for the given range.  If given a single
numeric argument, it will return an array containing the numbers from zero up to the
given number. Like the Python range() function, you can supply:

  • a stopping point,
  • a stopping point and a starting point, or
  • a starting point, stopping point and a step
Syntax


Code Block
sl.range(stop)
sl.range(start, stop)
sl.range(start, stop, step)


Example

Expression: sl.range(5)

Result:

Code Block
[
      0,
      1,
      2,
      3,
      4
    ]


Expression: sl.range(1,6)

Result:

Code Block
[
      1,
      2,
      3,
      4,
	  5	
    ]


Expression: sl.range(0,10,2)

Result:

Code Block
[
      0,
      2,
      4,
      6,
      8
    ]


sl.zip

DescriptionThis function takes arrays of the same length and returns an array of tuples that contain the values from the input arrays at the same indexes. This works similar to the Python zip() function.
Syntax


Code Block
sl.zip([array1], [array2],...)


Info

You can also use field parameters if they contain arrays of the same length, such as sl.zip($Alpha,$Beta).


Example

Expression: sl.zip([1, 2, 3], ['a', 'b', 'c'])

Result:

Code Block
[
      [
        1,
        "a"
      ],
      [
        2,
        "b"
      ],
      [
        3,
        "c"
      ]
    ]


sl.zipObject

DescriptionThis function returns an object composed from key-value pairs that accepts two arrays, the first with the properties and the second with values. This works similar to the Lodash zipObject function.
Syntax


Code Block
sl.zipObject([props=[]], [values=[]])


Info

You can also use field parameters if they contain arrays of the different lengths, but extra key values are set to null.


Examples

Expression: sl.zipObject([1, 2], ['a', 'b'])

Result:

Code Block
{a: 1, b: 2}


Expression: sl.zipObject ([1,2],['a'])

Result

Code Block
{'1': 'a', '2': null}


...