All files / piscosour/lib/utils paramUtils.js

100% Statements 14/14
100% Branches 4/4
100% Functions 2/2
100% Lines 14/14
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32    1x     16x 1x       1x   5x 5x 5x 5x 11x 6x   5x     5x     1x     2x      
'use strict';
 
const _ = require('lodash');
 
function overwriteArrays(obj, src) {
  if (_.isArray(obj)) {
    return src;
  }
}
 
module.exports = {
  refactorObjectsFromCommandLine(outputParams, key, value) {
    var output = _.merge({}, outputParams);
    var object = {};
    var result = object = {};
    key.split('.').forEach(((element, idx, array) => {
      if (idx !== array.length - 1) {
        object = object[ element ] = {};
      } else {
        object[ array[ array.length - 1 ] ] = value;
      }
    }));
    return _.merge(output, result);
  },
  mergeObjects(prioritario, segundo, mergeFunction) {
    return mergeFunction(prioritario, segundo);
  },
  mergeLodash(prioritario, complemento) {
    return _.mergeWith({}, complemento, prioritario, overwriteArrays);
  }
};