SL Functions and Properties
In this Page
sl.ensureArray
Description | Takes an argument and returns that argument unchanged if it is an array, otherwise it should return the argument in an array. |
---|---|
Syntax | sl.ensureArray(arg) |
Example | Expression: Result: [1,2,3] |
sl.gethostbyname
Description | Returns an array of IPv4 or IPv6 addresses for the given hostname or IP address. |
---|---|
Syntax | sl.gethostbyname(host) |
Example | Expression: Result: [ { "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
|
---|---|
Syntax | sl.range(stop) sl.range(start, stop) sl.range(start, stop, step) |
Example | Expression: Result: [ 0, 1, 2, 3, 4 ] Expression: Result: [ 1, 2, 3, 4, 5 ] Expression: Result: [ 0, 2, 4, 6, 8 ] |
sl.zip
Description | This 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 | sl.zip([array1], [array2],...) You can also use field parameters if they contain arrays of the same length, such as |
Example | Expression: Result: [ [ 1, "a" ], [ 2, "b" ], [ 3, "c" ] ] |
sl.zipObject
Description | This 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 | sl.zipObject([props=[]], [values=[]]) You can also use field parameters if they contain arrays of the different lengths, but extra key values are set to null. |
Examples | Expression:Â Result: {'1': 'a', '2': 'b'} Expression: Result:Â {'1': 'a', '2': null} |
Have feedback? Email documentation@snaplogic.com | Ask a question in the SnapLogic Community
© 2017-2024 SnapLogic, Inc.