Functions from I - L

if

Check whether an expression is true or false. Based on the result, return a specified value.

if(<expression>, <valueIfTrue>, <valueIfFalse>)

ParameterRequiredTypeDescription
<expression>YesBooleanThe expression to check
<valueIfTrue>YesanyThe value to return if the expression is true
<valueIfFalse>YesanyThe value to return if the expression is false
Return valueTypeDescription
<specified-return-value>anyThe specified value that returns based on whether the expression is true or false.

Example

This example evaluates whether equals(1,1) is true:

if(equals(1, 1), 'yes', 'no')

And returns yes because the specified expression returns true. Otherwise, the example returns no.

indexOf

Return the starting position or index value of a substring. This function is case-insensitive, and indexes start with the number 0.

indexOf('<text>', '<searchText>')

ParameterRequiredTypeDescription
<text>Yesstring or arrayThe string that has the substring to find
<searchText>YesstringThe substring to find
Return valueTypeDescription
<index-value>integerThe starting position or index value of the specified substring.
-1 (if the string isn't found)~If the string isn't found, return the number -1.

Example 1

This example finds the starting index value of the substring world in the string hello world:

indexOf('hello world', 'world')

And returns the result 6.

Example 2

This example finds the starting index value of the substring def in the array ['abc', 'def', 'ghi']:

indexOf(createArray('abc', 'def', 'ghi'), 'def')

And returns the result 1.

indicesAndValues

Turn an array or object into an array of objects with index (current index) and value properties. For arrays, the index is the position in the array. For objects, it's the key for the value.

indicesAndValues('<collection or object>')

ParameterRequiredTypeDescription
<collection or object>Yesarray or objectOriginal array or object
Return valueTypeDescription
<collection>arrayNew array. Each item has two properties: the index with the position in an array or the key for an object, and the corresponding value.

Example 1

Say you have a list { items: ["zero", "one", "two"] }. The following function takes that list:

indicesAndValues(items)

And returns a new list:

[
  {
    index: 0,
    value: 'zero'
  },
  {
    index: 1,
    value: 'one'
  },
  {
    index: 2,
    value: 'two'
  }
]

Example 2

Say you have a list { items: ["zero", "one", "two"] }. The following function takes that list:

where(indicesAndValues(items), elt, elt.index >= 1)

And returns a new list:

[
  {
    index: 1,
    value: 'one'
  },
  {
    index: 2,
    value: 'two'
  }
]

Example 3

Say you have a list { items: ["zero", "one", "two"] }. The following function takes that list:

join(foreach(indicesAndValues(items), item, item.value), ',')

And returns the result zero,one,two. This expression has the same effect as join(items, ',').

Example 4

Say you have an object { user: {name: 'jack', age: 20} }. The following function takes that object:

indicesAndValues(user)

And returns a new object:

[
  {
    index: 'name',
    value: 'jack'
  },
  {
    index: 'age',
    value: 20
  }
]

int

Return the integer version of a string. An exception will be thrown if the string can't be converted to an integer.

int('<value>')

ParameterRequiredTypeDescription
<value>YesstringThe string to convert
Return valueTypeDescription
<integer-result>integerThe integer version of the specified string

Example

This example creates an integer version for the string 10:

int('10')

And returns the result as the integer 10.

intersection

Return a collection that has only the common items across the specified collections. To appear in the result, an item must appear in all the collections passed to this function. If one or more items have the same name, the last item with that name appears in the result.

intersection([<collection1>], [<collection2>], ...)
intersection('<collection1>', '<collection2>', ...)

ParameterRequiredTypeDescription
<collection1>, <collection2>Yesarray or object, but not bothThe collections from which you want only the common items

Example

This example finds the common items across the following arrays:

intersection(createArray(1, 2, 3), createArray(101, 2, 1, 10), createArray(6, 8, 1, 2))

And returns an array with only the items [1, 2].

isArray

Return true if a given input is an array.

isArray('<input>')

ParameterRequiredTypeDescription
<input>YesanyThe input to be tested
Return valueTypeDescription
<Boolean-result>BooleanReturn true if a given input is an array, or return false if it's not an array.

Examples

The following examples check if the input is an array:

isArray('hello')
isArray(createArray('hello', 'world'))

And return the following results respectively:

  • The input is a string, so the function returns false.
  • The input is an array, so the function returns true.

isBoolean

Return true if a given input is a Boolean.

isBoolean('<input>')

ParameterRequiredTypeDescription
<input>YesanyThe input to be tested
Return valueTypeDescription
<Boolean-result>BooleanReturn true if a given input is a Boolean, or return false if it's not a Boolean.

Examples

The following examples check if the input is a Boolean:

isBoolean('hello')
isBoolean(32 > 16)

And return the following results respectively:

  • The input is a string, so the function returns false.
  • The input is a Boolean, so the function returns true.

isDate

Return true if a given TimexProperty or Timex expression refers to a valid date. Valid dates contain the month and dayOfMonth, or contain the dayOfWeek.

isDate('<input>')

ParameterRequiredTypeDescription
<input>Yesobject or stringThe input TimexProperty object or a Timex expression string.
Return valueTypeDescription
<boolean-result>BooleanReturn true if the input refers to a valid date, or return false if the date is invalid.

Examples

These examples check if the following inputs are valid dates:

isDate('2020-12')
isDate('xxxx-12-21')

And return the following results:

  • false
  • true

isDateRange

Return true if a given TimexProperty or Timex expression refers to a valid date range.

isDateRange('<input>')

ParameterRequiredTypeDescription
<input>Yesobject or stringThe input TimexProperty object a Timex expression string.
Return valueTypeDescription
<boolean-result>BooleanReturn true if given input refers to a valid date range, or return false if it's not a valid date range.

Examples

These examples check if the following input is a valid date range:

isDateRange('PT30M')
isDateRange('2012-02')

And return the following results:

  • false
  • true

isDateTime

Return true if a given input is a UTC ISO format (YYYY-MM-DDTHH:mm:ss.fffZ) timestamp string.

isDateTime('<input>')

ParameterRequiredTypeDescription
<input>YesanyThe input to be tested
Return valueTypeDescription
<Boolean-result>BooleanReturn true if a given input is a UTC ISO format timestamp string, or return false if it's not a UTC ISO format timestamp string.

Examples

The following examples check if the input is a UTC ISO format string:

isDateTime('hello world!')
isDateTime('2019-03-01T00:00:00.000Z')

And return the following results respectively:

  • The input is a string, so the function returns false.
  • The input is a UTC ISO format string, so the function returns true.

isDefinite

Return true if a given TimexProperty or Timex expression refers to a valid date. Valid dates contain the year, month and dayOfMonth.

isDefinite('<input>')

ParameterRequiredTypeDescription
<input>Yesobject or stringThe input TimexProperty object a Timex expression string.
Return valueTypeDescription
<boolean-result>BooleanReturn true if the given input refers to a valid full date, or return false if it doesn't refer to a valid full date.

Examples

Suppose there is a TimexProperty object validFullDate = new TimexProperty("2020-02-20") and the Now property is set to true. The following examples check if the object refers a valid full date:

isDefinite('xxxx-12-21')
isDefinite(validFullDate)

And return the following results respectively:

  • false
  • true

isDuration

Return true if a given TimexProperty or Timex expression refers to a valid duration.

isDuration('<input>')

ParameterRequiredTypeDescription
<input>Yesobject or stringThe input TimexProperty object a Timex expression string.
Return valueTypeDescription
<boolean-result>BooleanReturn true if the input refers to a valid duration, or return false if the input doesn't refer to a valid duration.

Examples

The examples below check if the following input refers to a valid duration:

isDuration('PT30M')
isDuration('2012-02')

And return the following results respectively:

  • true
  • false

isFloat

Return true if a given input is a floating-point number. Due to the alignment between C#and JavaScript, a number with an non-zero residue of its modulo 1 will be treated as a floating-point number.

isFloat('<input>')

ParameterRequiredTypeDescription
<input>YesanyThe input to be tested
Return valueTypeDescription
<Boolean-result>BooleanReturn true if a given input is a floating-point number, or return false if the input isn't a floating-point number.

Examples

The following examples check if the input is a floating-point number:

isFloat('hello world!')
isFloat(1.0)
isFloat(12.01)

And return the following results respectively:

  • The input is a string, so the function returns false.
  • The input has a modulo that equals 0, so the function returns false.
  • The input is a floating-point number, so the function returns true.

isInteger

Return true if a given input is an integer number. Due to the alignment between C# and JavaScript, a number with an zero residue of its modulo 1 will be treated as an integer number.

isInteger('<input>')

ParameterRequiredTypeDescription
<input>YesanyThe input to be tested
Return valueTypeDescription
<Boolean-result>BooleanIs the input is an integer number

Examples

The following examples check if the input is an integer:

isInteger('hello world!')
isInteger(1.0)
isInteger(12)

And return the following results respectively:

  • The input is a string, so the function returns false.
  • The input has a modulo that equals 0, so the function returns true.
  • The input is an integer, so the function returns true.

isObject('')

ParameterRequiredTypeDescription
<input>YesanyThe input to be tested
Return valueTypeDescription
<Boolean-result>BooleanReturn true if a given input is a complex object, or return false if it's a primitive object.

Examples

The following examples check if the given input is an object:

isObject('hello world!')
isObject({userName: "Sam"})

And return the following results respectively:

  • The input is a string, so the function returns false.
  • The input is an object, so the function returns true.

isPresent

Return true if a given TimexProperty or Timex expression refers to the present.

isPresent('')

ParameterRequiredTypeDescription
<input>Yesobject or stringThe input TimexProperty object a Timex expression string
Return valueTypeDescription
<boolean-result>BooleanReturn true if the input refers to the present, or return false if it doesn't refer to the present.

Examples Suppose we have an TimexProperty object validNow = new TimexProperty() { Now = true } and set the Now property to true. The examples below check if the following input refers to the present:

isPresent('PT30M')
isPresent(validNow)

And return the following results respectively:

  • false
  • true

isString

Return true if a given input is a string.

isString('')

ParameterRequiredTypeDescription
<input>YesanyThe input to be tested
Return valueTypeDescription
<Boolean-result>BooleanReturn true if a given input is a string, or return false if not a string.

Examples

The following examples check if the given input is a string:

isString('hello world!')
isString(3.14)

And return the following results respectively:

  • The input is a string, so the function returns true.
  • The input is a float, so the function returns false.

isTime

Return true if a given TimexProperty or Timex expression refers to a valid time. Valid time contains hours, minutes and seconds.

isTime('')

ParameterRequiredTypeDescription
<input>Yesobject or stringThe input TimexProperty object a Timex expression string
Return valueTypeDescription
<boolean-result>BooleanReturn true if the input refers to a valid time, or return false if it doesn't refer to a valid time.

Examples

These examples check if the following input refers to a valid time:

isTime('PT30M')
isTime('2012-02-21T12:30:45')

And return the following results respectively:

  • false
  • true

isTimeRange

Return true if a given TimexProperty or Timex expression refers to a valid time range Valid time ranges contain partOfDay.

isTime('')

ParameterRequiredTypeDescription
<input>Yesobject or stringThe input TimexProperty object a Timex expression string.
Return valueTypeDescription
<boolean-result>BooleanReturn true if the input refers to a valid time range, or return false if it doesn't refer to a valid time range.

Examples

Suppose we have an TimexProperty object validTimeRange = new TimexProperty() { PartOfDay = "morning" } and set the Now property to true. These examples check if the following inputs are valid time ranges:

isTimeRange('PT30M')
isTimeRange(validTimeRange)

And return the following results respectively:

  • false
  • true

join

Return a string that has all the items from an array, with each character separated by a delimiter.

join([], '')

ParameterRequiredTypeDescription
<collection>YesarrayThe array that has the items to join
<delimiter>YesstringThe separator that appears between each character in the resulting string
Return valueTypeDescription
<char1><delimiter><char2><delimiter>...stringThe resulting string created from all the items in the specified array.

Example

This example creates a string from all the items in this array with the specified character . as the delimiter:

join(createArray('a', 'b', 'c'), '.')

And returns the result a.b.c.


json

Return the JavaScript Object Notation (JSON) type value or object of a string or XML.

json('')

ParameterRequiredTypeDescription
<value>Yesstring or XMLThe string or XML to convert
Return valueTypeDescription
<JSON-result>stringThe resulting JSON object created from the specified string or XML.

Example 1

This example converts a string to JSON:

json('{"fullName": "Sophia Owen"}')

And returns the result:

{
"fullName": "Sophia Owen"
}

Example 2

This example converts XML to JSON:

json(xml(' Sophia Owen Engineer '))

And returns the result:

{  
   "?xml": { "@version": "1.0" },  
   "root": {  
      "person": [ {  
         "@id": "1",  
         "name": "Sophia Owen",  
         "occupation": "Engineer"  
      } ]  
   }  
}

jsonStringify

Return the JSON string of a value.

ParameterRequiredTypeDescription
<value>YesobjectThe object to convert to a JSON string
Return valueTypeDescription
<JSON-result>stringThe resulting JSON string.

Examples

These examples show objects converted to JSON strings:

jsonStringify(null)
jsonStringify({a:'b'})

And return the following string results respectively:

  • null
  • {"a":"b"}

last

Return the last item from a collection.

last('')
last([])

ParameterRequiredTypeDescription
<collection>Yesstring or arrayThe collection in which to find the last item
Return valueTypeDescription
<last-collection-item>string or array, respectivelyThe last item in the collection

Example

These examples find the last item in these collections:

last('abcd')
last(createArray(0, 1, 2, 3))

And returns the following results respectively:

  • d
  • 3

lastIndexOf

Return the starting position or index value of the last occurrence of a substring. This function is case-insensitive, and indexes start with the number 0.

lastIndexOf('', '')

ParameterRequiredTypeDescription
<text>Yesstring or arrayThe string that has the substring to find
<searchText>YesstringThe substring to find
Return ValueTypeDescription
<ending-index-value>integerThe starting position or index value of the last occurrence of the specified substring. If the string isn't found, return the number -1.

Example 1

This example finds the starting index value of the last occurrence of the substring world in the hello world string:

lastIndexOf('hello world', 'world')

And returns the result 6.

Example 2

This example finds the starting index value of the last occurrence of substring def in the array ['abc', 'def', 'ghi', 'def'].

lastIndexOf(createArray('abc', 'def', 'ghi', 'def'), 'def')

And returns the result 3.

length

Return the length of a string.

length('')

ParameterRequiredTypeDescription
<str>YesstringThe string to calculate for length
Return valueTypeDescription
<length>integerThe length of this string

Examples

These examples get the length of strings:

length('hello')
length('hello world')

And returns the following results respectively:

  • 5
  • 11

less

Check whether the first value is less than the second value. Return true if the first value is less, or return false if the first value is more.

less(, )
less('', '')

ParameterRequiredTypeDescription
<value>Yesinteger, float, or stringThe first value to check whether less than the second value.
<compareTo>Yesinteger, float, or stringThe comparison item.
Return ValueTypeDescription
true or falseBooleanReturn true if the first value is less than the second value. Return false if the first value is equal to or greater than the second value.

Examples

These examples check whether the first value is less than the second value.

less(5, 10)
less('banana', 'apple')

And return the following results respectively:

  • true
  • false

lessOrEquals

Check whether the first value is less than or equal to the second value. Return true if the first value is less than or equal, or return false if the first value is more.

lessOrEquals(, )
lessOrEquals('', '')

ParameterRequiredTypeDescription
<value>Yesinteger, float, or stringThe first value to check whether less than or equal to the second value.
<compareTo>Yesinteger, float, or stringThe comparison item.
Return ValueTypeDescription
true or falseBooleanReturn true if the first value is less than or equal to the second value. Return false if the first value is greater than the second value.

Example

These examples check whether the first value is less than or equal to the second value.

lessOrEquals(10, 10)
lessOrEquals('apply', 'apple')

And return the following results respectively:

  • true
  • false