Use utils.deflt for Settings (#649)
Rather than duplicate the definition of the undefined-defaulter, use the version already present in utils.
This commit is contained in:
parent
fdd83db65a
commit
f3df1ccbac
|
@ -3,12 +3,7 @@
|
||||||
* default settings.
|
* default settings.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
const utils = require("./utils");
|
||||||
* Helper function for getting a default value if the value is undefined
|
|
||||||
*/
|
|
||||||
function get(option, defaultValue) {
|
|
||||||
return option === undefined ? defaultValue : option;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main Settings object
|
* The main Settings object
|
||||||
|
@ -20,9 +15,9 @@ function get(option, defaultValue) {
|
||||||
function Settings(options) {
|
function Settings(options) {
|
||||||
// allow null options
|
// allow null options
|
||||||
options = options || {};
|
options = options || {};
|
||||||
this.displayMode = get(options.displayMode, false);
|
this.displayMode = utils.deflt(options.displayMode, false);
|
||||||
this.throwOnError = get(options.throwOnError, true);
|
this.throwOnError = utils.deflt(options.throwOnError, true);
|
||||||
this.errorColor = get(options.errorColor, "#cc0000");
|
this.errorColor = utils.deflt(options.errorColor, "#cc0000");
|
||||||
this.macros = options.macros || {};
|
this.macros = options.macros || {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user