From b96bff158ff3b73b8015a896b3961dccdd19c6d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Salgado?= Date: Tue, 3 Aug 2021 19:00:52 +0100 Subject: [PATCH] refactor: clean code related with removing the _path suffix --- lib/customers.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/customers.js b/lib/customers.js index b6cb4268..a3312c4b 100644 --- a/lib/customers.js +++ b/lib/customers.js @@ -270,12 +270,12 @@ function updateOverride (fields) { 'us_ssn' ] + const removePathSuffix = _.map(_.replace('_path', '')) + const getPairs = _.map(f => [`${f}_override`, 'automatic']) + const updatedFields = _.intersection(updateableFields, _.keys(fields)) - const overrideFields = _.fromPairs(_.map(f => - _.endsWith('_path', f) - ? [`${_.replace('_path', '_override', f)}`, 'automatic'] - : [`${f}_override`, 'automatic'] - , updatedFields)) + console.log('updatedFields', updatedFields) + const overrideFields = _.compose(_.fromPairs, getPairs, removePathSuffix)(updatedFields) return _.merge(fields, overrideFields) }