From fdea4a7c7ed2be84ea9efb1a859134b65c71ff73 Mon Sep 17 00:00:00 2001 From: darseen Date: Sun, 24 Dec 2023 15:46:59 +0300 Subject: [PATCH] Simplify initOptional function for clarity --- src/amadeus/client/validator.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/amadeus/client/validator.js b/src/amadeus/client/validator.js index 1fc2da0..1ac33a5 100644 --- a/src/amadeus/client/validator.js +++ b/src/amadeus/client/validator.js @@ -80,12 +80,9 @@ class Validator { } initOptional(key, options, fallback = null) { - let value = options[key]; //Env variables names expected to be in SNAKE_CASE and uppercase let envKey = `AMADEUS_${key.replace(/[A-Z]/g, c => `_${c.toLowerCase()}`).toUpperCase()}`; - if (value == undefined) { value = options[key]; } - if (value == undefined) { value = process.env[envKey]; } - if (value == undefined) { value = fallback; } + let value = options[key] || process.env[envKey] || fallback; return value; }