How to implement Peaka functions in JEXL
Click here for an introduction to using Peaka functions in JEXL
stringConcat(value)
This function converts the provided value into a string representation.
convertLocaleString(value, locale, options)
Converts a value to a string with a specified locale.
value
can be a number or date type and is required.locale
is your desired locale language (e.g., ‘fr’ for French, ‘tr’ for Turkish) and is required.options
is an optional object for customization, as shown below:
convertLocaleDateString(value, locale, options)
Converts a value to a string with a specified locale.
value
can be a string or date type and is required.locale
is your desired locale language (e.g., ‘fr’ for French, ‘tr’ for Turkish) and must be a string, and it’s required.options
is an optional object for customization, as shown below:
push(arr, value)
Appends a new value to an array.
arr
must be of type array and is a required parameter.value
can be of any data type and is also required.
addKey(object, key, value)
Adds a new key and value to an object.
object
must be an object type and is required.key
must be a string type and is required.- The type of
value
may be a string, number, date, object, array, and is required.
removeKey(object, key)
Deletes a key from an object.
object
must be an object type and is required.key
must be a string type and is required.
mapToKey(objects, key)
Retrieves values of a specified key.
objects
is an array that includes objects and is required.key
must be a string type and is required.
filterByKeys(objects, keys)
Filters objects by specified keys.
objects
is an array that includes objects and is required.keys
is an array of strings and is required
fromEntries(object)
Returns an array of keys and values from an object.
object
must be an object type and is required.
fromKeysAndValues(keys, values)
It creates an object with your keys and values. You need to enter them by your order.
keys
must be an array and is required.values
must be an array and is required.
uuid()
Generates a unique ID.
len(arr)
Returns the length of an array.
arr
is an array and is required.
updateKey(object, oldKey, newKey)
Updates a specified key. It finds the old key and replaces it with the new key.
object
must be an object type and is required.oldKey
must be a string type and is required.newKey
must be a string type and is required.
findDeep(arr,recursiveKey, searchKey, value)
Finds a value based on a search key and returns its value. If the value is not found or the search key’s value does not match, it returns ‘undefined’.
arr
may be an object or array type and is required.recursiveKey
is the key for recursive array searching. If not applicable, use an empty string (”).searchKey
is the key you are searching for.value
is the value to compare against the search key.
removeIndex(array, index)
Removes an element at a specified index.
array
must be an array and is required.index
must be number of string and is required.
jsonStringify(value)
This function converts the given value into a string representation.
value
can be of any data type and is a required parameter.
jsonParse(value)
This function parses the provided value, converting it from a string back into its original data structure.
value
can be of any data type and is a required parameter.
withQuotes(value)
The withQuotes function encloses a given string with quotation marks, both at the start and end.
value
must be of string type and is a required parameter.
trimQuotes(value)
This function removes leading and trailing quotation marks from a string.
value
must be of string type and is a required parameter.
fetch(url,options)
This function initiates an HTTP request.
url
is the URL for your request and is a required parameter.options
represent request configuration and is also required.
getQueryParameter(url, key)
The getQueryParameter function extracts a specific query parameter from a URL.
url
must be of string type and is required.key
is the parameter key to retrieve and is also required.
getQueryParameters()
This function returns all query parameters from a URL.
url
is your URL and is a required parameter.key
is the parameter key to retrieve, and it’s also required.
now()
The now function returns the current date and time.