BaseWithOptions

Monster.Types. BaseWithOptions

This is the base class with options from which some monster classes are derived.

This class is actually only used as a base class.

However, you can also create an instance directly via the monster namespace new Monster.Types.BaseWithOptions().

<script type="module">
import {Monster} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/monster.js';
new Monster.Types.BaseWithOptions()
</script>

Alternatively, you can also integrate this function individually.

<script type="module">
import {BaseWithOptions} from 'https://cdn.jsdelivr.net/npm/@schukai/monster@1.30.0/dist/modules/types/basewithoptions.js';
new BaseWithOptions()
</script>

Classes that require the possibility of options can be derived directly from this class. Derived classes almost always override the defaul getter with their own values.

class My extends BaseWithOptions {
   get defaults() {
       return Object.assign({}, super.defaults, {
           mykey: true
       });
   }  
}

The class was formerly called Object.

Constructor

# new BaseWithOptions(options)

Parameters:
Name Type Description
options object
Since:
  • 1.13.0

Members

# defaults

This getter provides the options. Derived classes overwrite this getter with their own values. It is good karma to always include the values from the parent class.

get defaults() {
    return Object.assign({}, super.defaults, {
        mykey: true
    });
}

Methods

# getOption(path, defaultValue) → {*}

nested options can be specified by path a.b.c

Parameters:
Name Type Description
path string
defaultValue *
Since:
  • 1.10.0
Returns:
Type
*