From f3df1ccbac4c61efd55bec423bc8509f8d173fb2 Mon Sep 17 00:00:00 2001 From: Tab Atkins Jr Date: Thu, 26 Jan 2017 22:54:05 -0800 Subject: [PATCH] Use utils.deflt for Settings (#649) Rather than duplicate the definition of the undefined-defaulter, use the version already present in utils. --- src/Settings.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/Settings.js b/src/Settings.js index b6b9659..128f6c7 100644 --- 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 || {}; }