commit f3df1ccbac4c61efd55bec423bc8509f8d173fb2
parent fdd83db65aa4d40fc688fb6cc1667d6f2c92461f
Author: Tab Atkins Jr <jackalmage@gmail.com>
Date: Thu, 26 Jan 2017 22:54:05 -0800
Use utils.deflt for Settings (#649)
Rather than duplicate the definition of the undefined-defaulter, use the version already present in utils.
Diffstat:
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/src/Settings.js b/src/Settings.js
@@ -3,12 +3,7 @@
* default settings.
*/
-/**
- * Helper function for getting a default value if the value is undefined
- */
-function get(option, defaultValue) {
- return option === undefined ? defaultValue : option;
-}
+const utils = require("./utils");
/**
* The main Settings object
@@ -20,9 +15,9 @@ function get(option, defaultValue) {
function Settings(options) {
// allow null options
options = options || {};
- this.displayMode = get(options.displayMode, false);
- this.throwOnError = get(options.throwOnError, true);
- this.errorColor = get(options.errorColor, "#cc0000");
+ this.displayMode = utils.deflt(options.displayMode, false);
+ this.throwOnError = utils.deflt(options.throwOnError, true);
+ this.errorColor = utils.deflt(options.errorColor, "#cc0000");
this.macros = options.macros || {};
}