Methods
-
staticLuCI.baseclass.extend(properties){LuCI.baseclass}
-
Extends this base class with the properties described in
propertiesand returns a new subclassed Class instanceName Type Description propertiesObject.<string, *> An object describing the properties to add to the new subclass.
Returns:
Type Description LuCI.baseclass Returns a new LuCI.baseclass subclassed from this class, extended by the given properties and with its prototype set to this base class to enable inheritance. The resulting value represents a class constructor and can be instantiated with new. -
staticLuCI.baseclass.instantiate(params){LuCI.baseclass}
-
Calls the class constructor using
newwith the given argument array being passed as variadic parameters to the constructor.Name Type Description paramsArray.<*> An array of arbitrary values which will be passed as arguments to the constructor function.
Returns:
Type Description LuCI.baseclass Returns a new LuCI.baseclass instance extended by the given properties with its prototype set to this base class to enable inheritance. -
Checks whether the given class value is a subclass of this class.
Name Type Description classValueLuCI.baseclass The class object to test.
Returns:
Type Description boolean Returns truewhen the givenclassValueis a subclass of this class orfalseif the given value is not a valid class or not a subclass of this class'. -
staticLuCI.baseclass.singleton(properties, new_args){LuCI.baseclass}
-
Extends this base class with the properties described in
properties, instantiates the resulting subclass using the additional optional arguments passed to this function and returns the resulting subclassed Class instance.This function serves as a convenience shortcut for
Class.extend()and subsequentnew.Name Type Description propertiesObject.<string, *> An object describing the properties to add to the new subclass.
new_args* optional repeatable Specifies arguments to be passed to the subclass constructor as-is in order to instantiate the new subclass.
Returns:
Type Description LuCI.baseclass Returns a new LuCI.baseclass instance extended by the given properties with its prototype set to this base class to enable inheritance. -
Walks up the parent class chain and looks for a class member called
keyin any of the parent classes this class inherits from. Returns the member value of the superclass or calls the member as a function and returns its return value when the optionalcallArgsarray is given.This function has two signatures and is sensitive to the amount of arguments passed to it:
super('key')- Returns the value ofkeywhen found within one of the parent classes.super('key', ['arg1', 'arg2'])- Calls thekey()method with parametersarg1andarg2when found within one of the parent classes.
Name Type Description keystring The name of the superclass member to retrieve.
callArgsArray.<*> optional An optional array of function call parameters to use. When this parameter is specified, the found member value is called as a function using the values of this array as arguments.
Throws:
-
Throws a
ReferenceErrorwhencallArgsare specified and the found member named bykeyis not a function value. - Type
- ReferenceError
Returns:
Type Description * | null Returns the value of the found member or the return value of the call to the found method. Returns nullwhen no member was found in the parent class chain or when the call to the superclass method returnednull. -
Extract all values from the given argument array beginning from
offsetand prepend any further given optional parameters to the beginning of the resulting array copy.Name Type Description argsArray.<*> The array to extract the values from.
offsetnumber The offset from which to extract the values. An offset of
0would copy all values till the end.extra_args* optional repeatable Extra arguments to add to prepend to the resulting array.
Returns:
Type Description Array.<*> Returns a new array consisting of the optional extra arguments and the values extracted from the argsarray beginning withoffset.