From 8abb861cab29a1133cb2bad47c5299c9b59030e4 Mon Sep 17 00:00:00 2001 From: Jesse Cotton Date: Mon, 2 Apr 2018 21:37:21 -0700 Subject: [PATCH] Enhance settings handling --- Orvibo.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Orvibo.js b/Orvibo.js index 9e2494b..b15dd6b 100644 --- a/Orvibo.js +++ b/Orvibo.js @@ -11,13 +11,12 @@ let ORVIBO_KEY = Settings.ORVIBO_KEY; let LOG_PACKET = Settings.LOG_PACKET; let PLUG_INFO = Settings.plugInfo; -const Orvibo = function(userSettings) { +const Orvibo = function(userSettings = {}) { // Allow user to pass in settings - if (userSettings != null) { - ORVIBO_KEY = userSettings.ORVIBO_KEY; - LOG_PACKET = userSettings.LOG_PACKET; - PLUG_INFO = userSettings.plugInfo; - } + if('ORVIBO_KEY' in userSettings) ORVIBO_KEY = userSettings.ORVIBO_KEY; + if('plugInfo' in userSettings) PLUG_INFO = userSettings.plugInfo; + if('PLUG_INFO' in userSettings) PLUG_INFO = userSettings.PLUG_INFO; + if('LOG_PACKET' in userSettings) LOG_PACKET = userSettings.LOG_PACKET; if (ORVIBO_KEY === '') { logger.log('Please pass Orvibo PK key details via the constructor or add to OrviboSettings.js file. See Readme');