Skip to main content

Values

Contains

a.Contains(b) -> boolean

Returns true if the a contains the given b.

  • If a is an array, returns true if b is an element of the array.
  • If a is a map, returns true if b is a value in the map.
  • If a is a range, returns true if b is a number within the range.
  • If a is a category, returns true if b is a subset or equal to a.
  • If a is a flag, returns true if b is a subset or equal to a.
  • If a is a string, returns true if b is a substring of a.

In all other cases, returns false.

CountBits

CountBits(x) -> number

Returns the number of bits set in the input. The input must be a Flag, unless it is nullish, in which case this function returns undefined.

IsEmpty

IsEmpty(x) -> boolean

Returns true if the value is empty, false otherwise. A value is empty if it is:

  • null or undefined
  • false
  • 0
  • @(0,0)
  • a String of length 0
  • an Array, Map or Range with no elements

Length

Length(x) -> value

Returns the length of x.

  • If x is a V2, returns the length of the vector.
  • If x is an array, returns the number of elements.
  • If x is a map, returns the number of key-value pairs.
  • If x is a string, returns the number of characters. Note that this requires iterating through the string as characters are stored as UTF-8.
  • Otherwise, returns undefined.

OrDefault

x.OrDefault(default) -> value

Returns the first argument if it is not undefined, otherwise returns the second argument.

Overlaps

a.Overlaps(b) -> boolean

Returns true if the a and b have any elements in common.

  • If a is a category and b is a category, returns true if they have any categories in common.
  • If a is a flag and b is a flag, returns true if they have any values in common.
  • Otherwise, returns false.

Slice

Slice(collection, from, length?) -> array

Returns a new array containing only the elements of the collection from from to from + length. Returns undefined if the input is nullish.

Parameters:

  • collection (Array): The collection to slice. Currently only Arrays are supported.
  • from (Number): The index to start slicing from. If negative, counts from the end of the array.
  • length (Number): The number of elements to include in the slice. If not provided, includes all elements from from to the end of the array.

Returns: A new array containing the sliced elements.