Documentation
API
Common

Common

Functions that work on many different types of values. Also see the experimental JSON functions.

equal

Returns true if the two values passed in are equal, false otherwise. Does not work for Squiggle functions, but works for most other types.

infix: ==
Namespace optional
Signatures
Common.equal(any, any) => Bool

unequal

infix: !=
Namespace optional
Signatures
Common.unequal(any, any) => Bool

typeOf

Returns the type of the value passed in as a string. This is useful when you want to treat a value differently depending on its type.

Namespace optional
Signatures
Common.typeOf(any) => String
Examples

inspect

Runs Console.log() in the Javascript developer console (opens in a new tab) and returns the value passed in.

Namespace optional
Signatures
Common.inspect('A, message?: String?) => 'A

throw

Throws an error. You can use try to recover from this error.

Namespace optional
Signatures
Common.throw(message: String?) => any

try

Try to run a function and return its result. If the function throws an error, return the result of the fallback function instead.

Namespace optional
Signatures
Common.try(fn: () => 'A, fallbackFn: () => 'B) => 'A|'B