HEX
Server: nginx/1.24.0
System: Linux nowruzgan 6.8.0-57-generic #59-Ubuntu SMP PREEMPT_DYNAMIC Sat Mar 15 17:40:59 UTC 2025 x86_64
User: babak (1000)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: /var/dev/nowruzgan/rest/node_modules/merge-dictionaries/index.js
var _ = require('@sailshq/lodash');

// Create the customized merge function.
var merge = function(dictA, dictB) {
  return _.merge(dictA, dictB, function(a, b) {
    // If `a` is not a POJO, or it's an empty POJO, just replace it with `b`.
    // _.isPlainObject is fine here because we don't care about clobbering dictionaries that
    // came from custom constructors; our use case is merging config files together, so any
    // left-hand values should either be literals, POJOS or `undefined`.
    if (!_.isPlainObject(a) || _.keys(a).length === 0) { return b; }
    // For non-empty dictionaries (POJO or otherwise), use the default merge strategy.
  });
};

// Allow variadic usage.
// e.g. mergeDictionarys(dictOne, dictTwo, dictThree, dictFour, ...)
module.exports = function() {

  // Special case: if only one arg is provided, just return it.
  if (arguments.length === 1) {
    return arguments[0];
  }

  // Otherwise use `_.reduce` to merge arguments from left to right.
  var args = Array.prototype.slice.call(arguments);
  var firstArg = args.shift();
  return _.reduce(args, function(memo, arg) {
    return merge(memo, arg);
  }, firstArg);

};