Utility

Functions to encode and decode or convert from a format to another one

decode Base64(string)

Base64 decode function

Parameters
Name Required Type Description

string

Yes

Text

Base64 encoded data

Returns

Text

Examples
utility.decode Base64("aGVsbG8=") => "hello"

decode JSON(string)

JSON decode function. Convert string to object

Parameters
Name Required Type Description

string

Yes

Text

Data as string

Returns

Any

Examples
utility.decode JSON("{\"name\":\"John\"}") => "{\"name\":\"John\"}"

encode Base64(data)

Base64 encode function

Parameters
Name Required Type Description

data

Yes

Text

Object

Returns

Text

Examples
utility.encode Base64("hello") => "aGVsbG8="

encode JSON(data)

JSON encode function. Convert Object/JSON to string

Parameters
Name Required Type Description

data

Yes

Any

String

Returns

Text

Examples
utility.encode JSON({"name":"John"}) => "\"{\"name\":\"John\"}\""

from epoch(timestamp)

Epoch function convert timestamp to date and time, timestamp is expressed in milliseconds and date and time is set to UTC

Parameters
Name Required Type Description

timestamp

Yes

Number

Timestamp expressed in milliseconds

Returns

Date and time

Examples
utility.from epoch(1511567100000) => "2017-11-24T23:45:00+00:00"

to epoch(dateTime)

Epoch function convert date and time to timestamp, timestamp is expressed in milliseconds. If date and time is not localized, it will be set to UTC

Parameters
Name Required Type Description

dateTime

Yes

Date and time

Date and time

Returns

Number

Examples
utility.to epoch(date and time(2017-11-24, 23:45:00)) => "1511567100000"

uri(scheme, host, [path], [parameters], [fragment])

Returns a properly encoded URI based on the passed scheme, host, path, parameters and fragment

Parameters
Name Required Type Description

scheme

Yes

Text

Refers to a specification for assigning identifiers

host

Yes

Text

Address of the server

path

No

Text | Collection of Text

Path to the resource

parameters

No

Any

Context

fragment

No

Text

Fragment

Returns

Text

Examples
utility.uri("https", "www.trisotech.com") => "https://www.trisotech.com"

utility.uri("https", "www.trisotech.com", "/path", {k: "value"}, "frag") => "https://www.trisotech.com/path?k=value#frag"

utility.uri("https", "www.trisotech.com", ["path1", "path2"]) => "https://www.trisotech.com/path1/path2"