SL Functions and Properties

In this Page

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
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
Example

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

Result:

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
Example

Expression: sl.range(5)

Result:


Expression: sl.range(1,6)

Result:


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

Result:

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
Example

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

Result:

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
Examples

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

Result:

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

Result