Helper Methods
HELPER
methods can help with data manipulation and transformation operations. These methods can be used to manipulate or transform data in String, Array and Object formats.
TRANSFORMDATATOARRAY
HELPER.TRANSFORMDATATOARRAY()
method can be used to transform an object to an array of objects. This method is useful when the data object has key-value pairs that represent the columns of a table.
HELPER.TRANSFORMDATATOARRAY(inputObject);
HELPER.TRANSFORMDATATOARRAY({
id: [1, 2, 3],
name: ['Jack', 'James', 'John'],
location: ['New York', 'London', 'Sydney']
});
[
{ id: 1, name: 'Jack', location: 'New york' },
{ id: 2, name: 'James', location: 'London' },
{ id: 3, name: 'John' , location: 'Sydney' }
]
TRANSFORMDATATOOBJECT
HELPER.TRANSFORMDATATOOBJECT()
method can be used to transform an array to an object. This method is useful when the data is an array of objects where each object has same set of keys.
HELPER.TRANSFORMDATATOOBJECT(inputArray);
HELPER.TRANSFORMDATATOOBJECT(
[
{ id: 1, name: 'Jack', location: 'New york' },
{ id: 2, name: 'James', location: 'London' },
{ id: 3, name: 'John' , location: 'Sydney' }
]
);
{
id: [1, 2, 3],
name: ['Jack', 'James', 'John'],
location: ['New York', 'London', 'Sydney']
}
INTERCHANGE
HELPER.INTERCHANGE()
method can be used to swap the position of two elements in an array.
HELPER.INTERCHANGE(inputArray,index1,index2);
Parameter | Accepts | Possible values |
---|---|---|
inputArray | array | array of elements |
index1 | integer | position index of first element |
index2 | integer | position index of second element |
HELPER.INTERCHANGE(["apple", "banana", "orange", "grape", "kiwi"],0,4);
["kiwi", "banana", "orange", "grape", "apple"]
MERGEARRAYS
HELPER.MERGEARRAYS()
method can be used to merge two arrays into one.
HELPER.MERGEARRAYS(array1,array2);
HELPER.MERGEARRAYS(["apple", "banana", "orange"], ["grapes", "pineapple"]);
["apple", "banana", "orange","grapes", "pineapple"]
CONCATENATE
HELPER.CONCATENATE()
method can be used to merge two or more strings into one.
HELPER.CONCATENATE(string1,string2,string3);
HELPER.CONCATENATE("hi ", "hello ", "How are you?");
"hi hello How are you?"
FLATTEN
HELPER.FLATTEN()
method can be used to convert a multi dimensional array into a single dimension array.
HELPER.FLATTEN([array1,array2,array3]);
HELPER.FLATTEN([1, [2, 3], [[4, 5], 6], [7, 8, [9, 10]]]);
[1,2,3,4,5,6,7,8,9,10]
RANGE
HELPER.RANGE()
method can be used to create an array of numbers for a specified range.
HELPER.RANGE(start,end);
HELPER.RANGE(5,10);
[5,6,7,8,9,10]
GETKEYVALUE
HELPER.GETKEYVALUE()
method can be used to get value of a specified key from object.
HELPER.GETKEYVALUE(object,key);
HELPER.GETKEYVALUE(
{
"key1": "DRONA",
"key2": "HQ",
"key3": "WELCOMES",
"key4": "YOU"
},"key1");
DRONA
ARRAYTOCSV
HELPER.ARRAYTOCSV()
method can be used to convert an array of arrays into csv format.
HELPER.GETKEYVALUE(array_of_arrays);
HELPER.ARRAYTOCSV(
[
["Name", "Age", "Location"],
["John Doe", 30, "New York"],
["Jane Smith", 25, "Los Angeles"]
]
);
Name, Age, Location
John Doe, 30, New York
Jane Smith, 25, Los Angeles