Namespace RapidContext.Fn

Fn

Provides predicate functions for type checking and equality.

Field Summary
(static)
eq
Checks if one or more values are equal.
(static)
Checks if an object has an own property with a specified key.
(static)
Checks if a value is set.
(static)
Checks if a value is Array-like.
(static)
Checks if a value is a bigint (i.e.
(static)
Checks if a value is a boolean` (i.e.
(static)
Checks if a value is an instance of Date.
(static)
Checks if a value is an instance of Error.
(static)
Checks if a value is a function (i.e.
(static)
Checks if a value is instanceof a constructor function.
(static)
Checks if a value is iterable (i.e.
(static)
Checks if a value is either null or undefined.
(static)
Checks if a value is null (but not undefined).
(static)
Checks if a value is a number (i.e.
(static)
Checks if a value is a plain Object (and not based on another prototype).
(static)
Checks if a value is an instance of Promise.
(static)
Checks if a value is an instance of RegExp.
(static)
Checks if a value is Set-like.
(static)
Checks if a value is a string (i.e.
(static)
Checks if typeof(val) matches a string or an array element.
(static)
Checks if a value is undefined (but not null).

Members

(static) eq

Checks if one or more values are equal. Supports recursively comparing both arrays and objects, as well as standard values. Returns a bound function if only the first argument is specified. Also returns a bound function if one argument is a function.

Parameters:
Name Type Attributes Description
values {*} <repeatable>
the values to compare
Returns:
{boolean|function} the test result, or a bound function
Examples:
eq(1, 1, 1, 3) //==> false
eq({ a: 1, b: 2 }, { b: 2, a: 1 }) //==> true
let isAbc = eq("abc");
isAbc("abc") //==> true
let hasValidA = eq(42, get("a"));
hasValidA({ a: 42 }) //==> true
Source:
rapidcontext/fn.mjs, line 299

(static) hasProperty

Checks if an object has an own property with a specified key. Returns a bound function if only the first argument is specified.

Parameters:
Name Type Attributes Description
key {string} the property key to check for
obj {Object} <optional>
the object to check
Returns:
{boolean|function} the match result, or a bound function
Source:
rapidcontext/fn.mjs, line 257

(static) hasValue

Checks if a value is set. Returns false for null, undefined, empty arrays, empty objects or empty strings. Boolean false and 0 will return true, as these are defined values.

Parameters:
Name Type Description
val {*} the value to check
Returns:
{boolean} true if the value is set, or false otherwise
Source:
rapidcontext/fn.mjs, line 275

(static) isArrayLike

Checks if a value is Array-like. This is an object with a numeric length property (but not a function).

Parameters:
Name Type Description
val {*} the value to check
Returns:
{boolean} true on match, or false otherwise
Source:
rapidcontext/fn.mjs, line 218

(static) isBigInt

Checks if a value is a bigint (i.e. typeof(..) = "bigint").

Parameters:
Name Type Description
val {*} the value to check
Returns:
{boolean} true on match, or false otherwise
Source:
rapidcontext/fn.mjs, line 110

(static) isBoolean

Checks if a value is a boolean (i.e. typeof(..) = "boolean"`).

Parameters:
Name Type Description
val {*} the value to check
Returns:
{boolean} true on match, or false otherwise
Source:
rapidcontext/fn.mjs, line 74

(static) isDate

Checks if a value is an instance of Date.

Parameters:
Name Type Description
val {*} the value to check
Returns:
{boolean} true on match, or false otherwise
Source:
rapidcontext/fn.mjs, line 180

(static) isError

Checks if a value is an instance of Error.

Parameters:
Name Type Description
val {*} the value to check
Returns:
{boolean} true on match, or false otherwise
Source:
rapidcontext/fn.mjs, line 168

(static) isFunction

Checks if a value is a function (i.e. typeof(..) = "function").

Parameters:
Name Type Description
val {*} the value to check
Returns:
{boolean} true on match, or false otherwise
Source:
rapidcontext/fn.mjs, line 86

(static) isInstanceOf

Checks if a value is instanceof a constructor function. Returns a bound function if only the first argument is specified.

Parameters:
Name Type Description
constructor {function} the constructor function or class
val {*} the value to check
Returns:
{boolean|function} the match result, or a bound function
Source:
rapidcontext/fn.mjs, line 150

(static) isIterable

Checks if a value is iterable (i.e. follows the iterable protocol). This is an object with a Symbol.iterator method returning the values.

Parameters:
Name Type Description
val {*} the value to check
Returns:
{boolean} true on match, or false otherwise
Source:
rapidcontext/fn.mjs, line 244

(static) isNil

Checks if a value is either null or undefined.

Parameters:
Name Type Description
val {*} the value to check
Returns:
{boolean} true on match, or false otherwise
Source:
rapidcontext/fn.mjs, line 20

(static) isNull

Checks if a value is null (but not undefined).

Parameters:
Name Type Description
val {*} the value to check
Returns:
{boolean} true on match, or false otherwise
Source:
rapidcontext/fn.mjs, line 32

(static) isNumber

Checks if a value is a number (i.e. typeof(..) = "number").

Parameters:
Name Type Description
val {*} the value to check
Returns:
{boolean} true on match, or false otherwise
Source:
rapidcontext/fn.mjs, line 98

(static) isObject

Checks if a value is a plain Object (and not based on another prototype).

Parameters:
Name Type Description
val {*} the value to check
Returns:
{boolean} true on match, or false otherwise
Source:
rapidcontext/fn.mjs, line 134

(static) isPromise

Checks if a value is an instance of Promise.

Parameters:
Name Type Description
val {*} the value to check
Returns:
{boolean} true on match, or false otherwise
Source:
rapidcontext/fn.mjs, line 204

(static) isRegExp

Checks if a value is an instance of RegExp.

Parameters:
Name Type Description
val {*} the value to check
Returns:
{boolean} true on match, or false otherwise
Source:
rapidcontext/fn.mjs, line 192

(static) isSetLike

Checks if a value is Set-like. This is an object with a numeric size property, and has() and keys() methods.

Parameters:
Name Type Description
val {*} the value to check
Returns:
{boolean} true on match, or false otherwise
Source:
rapidcontext/fn.mjs, line 231

(static) isString

Checks if a value is a string (i.e. typeof(..) = "string").

Parameters:
Name Type Description
val {*} the value to check
Returns:
{boolean} true on match, or false otherwise
Source:
rapidcontext/fn.mjs, line 122

(static) isTypeOf

Checks if typeof(val) matches a string or an array element. Returns a bound function if only the first argument is specified.

Parameters:
Name Type Attributes Description
type {string|Array} the type name or array of type names
val {*} <optional>
the value to check
Returns:
{boolean|function} the match result, or a bound function
Source:
rapidcontext/fn.mjs, line 44

(static) isUndefined

Checks if a value is undefined (but not null).

Parameters:
Name Type Description
val {*} the value to check
Returns:
{boolean} true on match, or false otherwise
Source:
rapidcontext/fn.mjs, line 62