Values
Contains
a.Contains(b) -> boolean
Returns true
if the a
contains the given b
.
- If
a
is an Array, returns true ifb
is an element of the Array. - If
a
is a Map, returns true ifb
is a value in the Map. - If
a
is a Range, returns true ifb
is a number within the Range. - If
a
is a Category, returns true ifb
is a subset or equal toa
. - If
a
is a Flag, returns true ifb
is a subset or equal toa
. - If
a
is a String, returns true ifb
is a substring ofa
.
In all other cases, returns false
.
CountBits
x.CountBits -> number
CountBits(x) -> number
Returns the number of bits set in the input.
The input must be a Flag or Category,
unless it is nullish, in which case this function returns undefined
.
IsEmpty
x.IsEmpty -> boolean
IsEmpty(x) -> boolean
Returns true
if the value is empty, false
otherwise.
A value is empty if it is:
null
orundefined
false
0
@(0,0)
- a String of length 0
- an Array, Map or Range with no elements
Length
x.Length -> value
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 Range, returns the number of steps in the range. - 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, and so the time taken for this calculation is proportional to the length of the string. - 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
andb
are both Categories, returnstrue
if they have any categories in common. - If
a
andb
are both Flags, returnstrue
if they have any values in common. - Otherwise, returns
false
.