Module: @lumjs/core/opt

Functions for working with options and default values.

Source:

Classes

Opts

Methods

(static) get(obj, optname, defvalue, allowNullopt, isLazyopt, lazyThisopt, lazyArgsopt) → {*}

See if a property in an object is set.

If it is, return the property, otherwise return a default value. This uses the val() method, and as such supports the same options. However read the parameters carefully, as the defaults may be different!

Parameters:
Name Type Attributes Default Description
obj object

An object to test for a property in.

optname string

The property name we're checking for.

defvalue *

The default value.

allowNull bool <optional>
true

Same as val(), but default is true.

isLazy bool <optional>
false

Same as val().

lazyThis object <optional>
opts

Same as val(), but default is obj.

lazyArgs Array <optional>

Same as val().

Source:
Returns:

Either the property value, or the default value.

Type
*

(static) val(optvalue, defvalue, allowNullopt, isLazyopt, lazyThisopt, lazyArgsopt) → {*}

See if a value is set, and if not, return a default value.

Parameters:
Name Type Attributes Default Description
optvalue *

The value we are testing.

defvalue *

The default value if opt was null or undefined.

allowNull boolean <optional>
false

If true, allow null to count as set.

isLazy boolean <optional>
false

If true, and defvalue is a function, use the value from the function as the default.

lazyThis object <optional>
null

If isLazy is true, this object will be used as this for the function.

lazyArgs Array <optional>

If isLazy is true, this may be used as a list of arguments to pass.

Source:
Returns:

Either the specified opt value or the default value.

Type
*