Skip to main content

Lang functions

The following list contains general purpose functions.


cast_array()#

Casts value as an array if it's not one.

cast_array(value)

Arguments#

value (Any)
The value to process.

Returns#

(Array)
Returns the cast array.

Examples#

InputExpressionResult
1
cast_array(@)
[1]
[1]
cast_array(@)
[1]
{ "a": 1 }
cast_array(@)
[{ "a": 1 }]

conforms_to()#

Checks if object conforms to source by invoking the predicate properties of source with the corresponding property values of object.

conforms_to(object, source)

Arguments#

object (Object)
The object to process.
source (Object)
The object of property predicates to conform to.

Returns#

(boolean)
true if object conforms, else false.

Examples#

InputExpressionResult
{    "version": 2,    "action": {        "type": "create"    }}
conforms_to(@, {version: &version>1})
true

eq()#

Compare two values to determine if they are equivalent.

eq(value, other)

Arguments#

value (Any)
The value to compare.
other (Any)
The other value to compare.

Returns#

(Boolean)
true if values are equivalent, else false.

Examples#

InputExpressionResult
[{ "a": 1 }, { "a": 1 }]
eq([0][0], [1][0])
true
[1, [1]]
eq([0][0], [1][0])
false
[]
eq(NaN, NaN)
true
[]
eq(null, null)
true

gt()#

Checks if value is greater than other.

gt(value, other)

Arguments#

value (Any)
The value to compare.
other (Any)
The other value to compare.

Returns#

(Boolean)
true if value is greater than other, else false.

Examples#

InputExpressionResult
[{ "a": 2 }, { "a": 1 }]
gt([0].a, [1].a)
true
[{ "a": 2 }, 1]
gt([0].a, [1])
true
[1, 2]
gt([1], [0])
true
[2, 2]
gt([0], [1])
false

See also#


gte()#

Checks if value is greater or equal to other.

gte(value, other)

Arguments#

value (Any)
The value to compare.
other (Any)
The other value to compare.

Returns#

(Boolean)
true if value is greater or equal to other, else false.

Examples#

InputExpressionResult
[{ "a": 2 }, { "a": 2 }]
gte([0].a, [1].a)
true
[3, 2]
gte([1], [0])
false
[2, 2]
gt([0], [1])
true

See also#


is_array()#

Checks if value is classified as an Array object.

is_array(value)

Arguments#

value (Any)
The value to check.

Returns#

(Boolean)
true if value is an array, else false.

Examples#

InputExpressionResult
[1, 2]
is_array(@)
true
{ "a": 1, "b": 2 }
is_array(@)
false
"Hello World"
is_array(@)
false

See also#


is_array_buffer()#

Checks if value is classified as an ArrayBuffer object.

is_array_buffer(value)

Arguments#

value (Any)
the value to check.

Returns#

(Boolean)
true if value is an ArrayBuffer object, else false.

Examples#

TBD

See also#


is_array_like()#

Checks if value is array-like. A value is considered array-like if it's not a function and has a length() that's an integer greater than or equal to 0 and less than or equal to 2^53 - 1 (MAX_SAFE_INTEGER constant in JavaScript).

is_array_like(value)

Arguments#

value (Any)
The value to check.

Returns#

(Boolean)
true if value is an array-like, else false.

Examples#

InputExpressionResult
[1, 2]
is_array_like(@)
true
{ "a": 1, "b": 2 }
is_array_like(@)
false
[{ "a": 1, "b": 2 }]
is_array_like(@)
true
"Hello World"
is_array_like(@)
true
[]
is_array_like(date_now)
false

See also#


is_boolean()#

Checks if value is classified as a boolean primitive or object.

is_boolean(value)

Arguments#

value (Any)
The value to check.

Returns#

(Boolean)
true if value is boolean, else false.

Examples#

InputExpressionResult
[1, 2]
is_boolean(@)
false
false
is_boolean(@)
true

See also#


is_buffer()#

Checks if value is classified as a buffer.

is_buffer(value)

Arguments#

value (Any)
The value to check.

Returns#

(Boolean)
true if value is buffer, else false.

Examples#

TBD

See also#


is_date()#

Checks if value is classified as a Date object.

is_date(value)

Arguments#

value (Any)
The value to check.

Returns#

(Boolean)
true if value is Date object, else false.

Examples#

TBD

See also#


is_empty()#

Checks if value is an empty object, collection, map, or set.

Objects are considered empty if they have no own enumerable string keyed properties. Array-like values such as arguments objects, arrays, buffers, or strings are considered empty if they have a length of 0. Similarly, maps and sets are considered empty if they have a size of 0.

is_empty(value)

Arguments#

value (Any)
The value to check.

Returns#

(Boolean)
true if value is empty, else false.

Examples#

InputExpressionResult
[1, 2]
is_empty(@)
false
{ "a": 1 }
is_empty(@)
false
[]
is_empty(@)
true
1
is_empty(@)
true
[]
is_empty(null)
true

See also#


is_error()#

Checks if value is an Error.

is_error(value)

Arguments#

value (Any)
The value to check.

Returns#

(Boolean)
true if value is an error, else false.

Examples#

TBD

See also#


is_finite()#

Checks if value is a finite primitive number.

is_finite(value)

Arguments#

value (Any)
The value to check.

Returns#

(Boolean)
true if value is finite number, else false.

Examples#

InputExpressionResult
[1, 2]
is_finite(@)
false
100
is_finite(@)
true
[0, 10]
is_finite(divide([1], [0]))
false

See also#


is_function()#

Checks if value is classified as a Function object.

is_function(value)

Arguments#

value (Any)
The value to check.

Returns#

(Boolean)
true if value is a function, else false.

Examples#

TBD


is_integer()#

Checks if value is an Integer number.

is_integer(value)

Arguments#

value (Any)
The value to check.

Returns#

(Boolean)
true if value is an integer number, else false.

Examples#

InputExpressionResult
3
is_integer(@)
true
"3.5"
is_integer(@)
false
"3"
is_integer(@)
false
[3]
is_integer(@)
false

See also#


is_map()#

Checks if value is classified as a Map object.

is_map(value)

Arguments#

value (Any)
The value to check.

Returns#

(Boolean)
true if value is a Map, else false.

Examples#

TBD


is_match()#

Performs a partial deep comparison between object and source to determine if object contains equivalent property values.

Partial comparisons will match empty array and empty object source values against any array or object value, respectively.

is_match(object, source)

Arguments#

object (Object)
The object to process.
source (Object)
The object of property values to match.

Returns#

(Boolean)
true if property of an object matches, else false.

Examples#

InputExpressionResult
{ "a": 1, "b": 2 }
is_match(@, {a: 1})
true
{ "a": 1, "b": 2 }
is_match(@, {a: 2})
false

See also#


is_nan()#

Checks if value is NaN.

is_nan(value)

Arguments#

value (Any)
The value to check.

Returns#

(Boolean)
true if value is a NaN, else false.

Examples#

InputExpressionResult
[1, 2]
is_nan(to_number(@))
true
1
is_nan(@)
false

See also#


is_null()#

Checks if value is null.

is_null(value)

Arguments#

value (Any)
The value to check.

Returns#

(Boolean)
true if value is null, else false.

Examples#

InputExpressionResult
null
is_null(null)
true
"string"
is_null(@)
false
[1, 2, 3]
is_null(@)
false

See also#


is_number()#

Checks if value is a Number.

is_number(value)

Arguments#

value (Any)
The value to check.

Returns#

(Boolean)
true if value is Number, else false.

Examples#

InputExpressionResult
3
is_number(@)
true
"3"
is_number(@)
false

See also#


is_object()#

Checks if value is an Object (e.g. Arrays, Objects, Functions, etc. See ECMAScript Object type spec).

is_object(value)

Arguments#

value (Any)
The value to check.

Returns#

(Boolean)
true if value is Object, else false.

Examples#

InputExpressionResult
{ "a": 1, "b": 2 }
is_object(@)
true
[1, 2]
is_object(@)
true
5.3
is_object(&floor(@))
true
"Hello World"
is_object(@)
false
100
is_object(@)
false

See also#


is_object_like()#

Checks if value is object-like. A value is object-like if it's not null and has a type() result of "object".

is_object_like(value)

Arguments#

value (Any)
The value to check.

Returns#

(Boolean)
true if value is an object-like, else false.

Examples#

InputExpressionResult
{ "a": 1, "b": 2 }
is_object_like(@)
true
[1, 2]
is_object_like(@)
true
"Hello World"
is_object_like(@)
false

See also#


is_plain_object()#

Checks if value is a plain object. Plain object is an unordered set of name/value pairs that begins with { and ends with }.

is_plain_object(value)

Arguments#

value (Any)
The value to check.

Returns#

(Boolean)
true if value is a plain object, else false.

Examples#

InputExpressionResult
{ "a": 1, "b": 2 }
is_plain_object(@)
true
[1, 2]
is_plain_object(@)
false

See also#


is_regexp()#

Checks if value is classified as a RegExp object.

is_regexp(value)

Arguments#

value (Any)
The value to check.

Returns#

(Boolean)
true if value is a RegExp, else false.

Examples#

InputExpressionResult
"[a-z]"
is_regexp(regexp(@))
true
"[a-z]"
is_regexp(@)
false

is_safe_integer()#

Checks if value is a safe integer. An integer is safe if it's an double precision number (IEEE-754 standard) which isn't the result of a rounded unsafe integer.

is_safe_integer(value)

Arguments#

value (Any)
The value to check.

Returns#

(Boolean)
true if value is a safe integer, else false.

Examples#

InputExpressionResult
3
is_safe_integer(@)
true
3.33
is_safe_integer(@)
false
"3"
is_safe_integer(@)
false

See also#


is_set()#

Checks if value is classified as a Set object.

is_set(value)

Arguments#

value (Any)
The value to check.

Returns#

(Boolean)
true if value is a Set, else false.

Examples#

TBD


is_string()#

Checks if value is classified as a String primitive or object.

is_string(value)

Arguments#

value (Any)
The value to check.

Returns#

(Boolean)
true if value is a String, else false.

Examples#

InputExpressionResult
"abc"
is_string(@)
true
1
is_string(@)
false

See also#


is_symbol()#

Checks if value is classified as a Symbol primitive or object.

is_symbol(value)

Arguments#

value (Any)
The value to check.

Returns#

(Boolean)
true if value is a Symbol, else false.

Examples#

TBD


is_typed_array()#

Checks if value is classified as a typed array.

is_typed_array(value)

Arguments#

value (Any)
The value to check.

Returns#

(Boolean)
true if value is a typed array, else false.

Examples#

TBD


lt()#

Checks if value is less than other.

lt(value, other)

Arguments#

value (Any)
The value to compare.
other (Any)
The other value to compare.

Returns#

(Boolean)
true if value is less than other, else false.

Examples#

InputExpressionResult
[{ "a": 1 }, { "a": 2 }]
lt([0].a, [1].a)
true
[1, 2]
lt([1], [0])
false
[2, 2]
lt([0], [1])
false

See also#


lte()#

Checks if value is less or equal to other.

lte(value, other)

Arguments#

value (Any)
The value to compare.
other (Any)
The other value to compare.

Returns#

(Boolean)
true if value is less or equal to other, else false.

Examples#

InputExpressionResult
[{ "a": 2 }, { "a": 2 }]
lte([0].a, [1].a)
true
[3, 2]
lte([0], [1])
false

See also#


to_array()#

Converts value to an array.

to_array(value)

Arguments#

value (Any)
The value to convert.

Returns#

(Array)
Converted array.

Examples#

InputExpressionResult
[1, 2]
to_array(@)
[1, 2]
{ "a": 1, "b": 2 }
to_array(@)
[1, 2]
"abc"
to_array(@)
["a", "b", "c"]
1
to_array(@)
[]

See also#


to_finite()#

Converts value to a finite number.

to_finite(value)

Arguments#

value (Any)
The value to convert.

Returns#

(Number)
Converted number.

Examples#

InputExpressionResult
3.2
to_finite(@)
3.2
[3.2]
to_finite(@)
3.2
[1, 2]
to_finite(@)
0
"abc"
to_finite(@)
0
[]
to_finite(divide(10, 0))
1.7976931348623157e+308a

See also#


to_integer()#

Converts value to an integer.

to_integer(value)

Arguments#

value (Any)
The value to convert.

Returns#

(Number)
Converted number.

Examples#

InputExpressionResult
3.2
to_integer(@)
3
[3.2]
to_integer(@)
3
[1, 2]
to_integer(@)
0
"3.2"
to_integer(@)
3
[]
to_integer(divide(10, 0))
1.7976931348623157e+308a

See also#


to_number()#

Converts value to a number.

to_number(value)

Arguments#

value (Any)
The value to convert.

Returns#

(Number)
Converted number.

Examples#

InputExpressionResult
3.2
to_number(@)
3.2
[3.2]
to_number(@)
3.2
[1, 2]
to_number(@)
NaN
"3.2"
to_number(@)
3.2
[]
to_number(divide(10, 0))
null

See also#


to_plain_object()#

Converts value to a plain object flattening inherited enumerable string keyed properties of value to own properties of the plain object.

to_plain_object(value)

Arguments#

value (Any)
The value to convert.

Returns#

(Object)
Converted plain object.

Examples#

InputExpressionResult
[1, 2]
to_plain_object(@)
{ "0": 1, "1": 2 }
[    ["a", 1],    ["b", 2]]
to_plain_object(@)
{    "0": ["a", 1],    "1": ["b", 2]}
"abc"
to_plain_object(@)
{    "0": "a",    "1": "b",    "2": "c"}
125
to_plain_object(@)
{}

See also#


to_safe_integer()#

Converts value to a safe integer.

to_safe_integer(value)

Arguments#

value (Any)
The value to convert.

Returns#

(Number)
Converted integer.

Examples#

InputExpressionResult
3.2
to_safe_integer(@)
3
"3.2"
to_safe_integer(@)
3
[]
to_safe_integer(divide(10, 0))
9007199254740991

See also#


to_string()#

Converts value to a String. An empty string is returned for null and undefined values. The sign of -0 is preserved.

to_string(value)

Arguments#

value (Any)
The value to convert.

Returns#

(String)
Converted String.

Examples#

InputExpressionResult
[]
to_string(@)
""
[1, 2]
to_string(@)
"1,2"
{ "a": 1 }
to_string(@)
[object Object]
-5
to_string(@)
"-5"

See also#


regexp()#

Constructs RegExp object that can be used for matching text with a pattern.

regexp(pattern, [flags])

Arguments#

pattern (String)
The text of RegExp expression.
flags (String)
Optional. The flags that affect the RegExp search. There are only 6 of them:
i: Case-insensitive search.
g: Looks for all matches. Without this flag only the first match is returned.
m: Multiline mode.
s: Enables “dotall” mode, that allows a dot . to match newline character \n.
u: Enables full Unicode support.
y: “Sticky” mode: searching at the exact position in the text.

Returns#

(RegExp)
Created RegExp object.

Examples#

TBD

See also#


type()#

Determines the type of the value.

type(value)

Arguments#

value (Any)
The value to inspect.

Returns#

(String)
The type of the inspected argument.

Examples#

InputExpressionResult
[]
type(@)
"array"
{}
type(@)
"object"
"abc"
type(@)
"string"
125
type(@)
"number"
true
type(@)
"boolean"
null
type(@)
"null"

  • cast_array()
  • conforms_to()
  • eq()
  • gt()
  • gte()
  • is_array()
  • is_array_buffer()
  • is_array_like()
  • is_boolean()
  • is_buffer()
  • is_date()
  • is_empty()
  • is_error()
  • is_finite()
  • is_function()
  • is_integer()
  • is_map()
  • is_match()
  • is_nan()
  • is_null()
  • is_number()
  • is_object()
  • is_object_like()
  • is_plain_object()
  • is_regexp()
  • is_safe_integer()
  • is_set()
  • is_string()
  • is_symbol()
  • is_typed_array()
  • lt()
  • lte()
  • to_array()
  • to_finite()
  • to_integer()
  • to_number()
  • to_plain_object()
  • to_safe_integer()
  • to_string()
  • regexp()
  • type()