How to use the merge function from lodash

Find comprehensive JavaScript lodash.merge code examples handpicked from public code repositorys.

85
86
87
88
89
90
91
92
93
94
},
loadConfig (filename, { env } = process) {
  const config = this.getDefaults({ env })
  if (filename) {
    try {
      _.merge(config, this.readConfig(filename))
    } catch (err) { /* ignore */ }
  }
  this.assignEnvironmentVariables(config, env)
  const requiredConfigurationProperties = [
fork icon88
star icon199
watch icon22

+ 2 other calls in file

19
20
21
22
23
24
25
26
27
28
29
30
);


const handledOutcomes = new Set(['success', 'error:handled']);


module.exports = async (basename, coreConfig, options) => {
  const baseLambdaConfiguration = _.merge(
    {
      Role: coreConfig.roleArn,
      MemorySize: 1024,
      Layers: [coreConfig.layerInternalArn],
fork icon7
star icon19
watch icon12

+ 5 other calls in file

252
253
254
255
256
257
258
259
260
261
262
263
        assert(upgradeAttrs._attrs.upgradeLevel);
        assert(
            (this._attrs.upgradeLevel || 0) <= upgradeAttrs._attrs.upgradeLevel
        );


        _.merge(this._attrs, upgradeAttrs._attrs);
    }
}


// Export for unittest
fork icon14
star icon17
watch icon6

+ 12 other calls in file

1939
1940
1941
1942
1943
1944
1945
1946
1947
1948

  if(typeof this.options.server.https == 'object' && this.options.server.https.ca) {
    options.agent.options.ca = this.options.server.https.ca;
  }

  return _.merge(defaults, options);
}

/**
 * Create the request network options
fork icon4
star icon14
watch icon4

+ 188 other calls in file

18
19
20
21
22
23
24
25
26
}

if (!addresses[realm]) addresses[realm] = {}
if (!addresses[realm][chain]) addresses[realm][chain] = {}

const artifactNames = merge(
  settings.artifacts.default,
  settings.artifacts[realm]
)
fork icon22
star icon6
watch icon4

42
43
44
45
46
47
48
49
50
51
52
  return a._id === b._id;
};


Observer.prototype.loadInitial = function (cb) {
  var self = this;
  var newQuery = _.merge(this._query, self._queryOptions);
  this._collection._getDocuments(newQuery, function (err, result) {
    if (self._options.init) {
      self._options.init(result);
    } else {
fork icon1
star icon0
watch icon14

75
76
77
78
79
80
81
82
83
self.project.resourceZone = options.resourceZone;
self.project.serviceAccountPath = path.resolve(self.cwd, options.serviceAccountPath)
self.project.backendManagerConfigPath = path.resolve(self.cwd, options.backendManagerConfigPath)

self.package = resolveProjectPackage();
self.config = merge(
  requireJSON5(self.project.backendManagerConfigPath),
  self.libraries.functions.config()
);
fork icon0
star icon2
watch icon2

+ 15 other calls in file

76
77
78
79
80
81
82
83
84
85
86
  }
  return [query, options, callback]
}


module.exports = async function (config = {}) {
  config = _.merge({}, DEFAULT_CONFIG, config)
  if (config.timestamps === true) {
    config.timestamps = DEFAULT_TIMESTAMPS
  }
  const client = new MongoClient(config.url, config.connection)
fork icon0
star icon2
watch icon1

321
322
323
324
325
326
327
328
329
330
331
332
333


config.path.base = `${config.path.prefix}/${config.path.app}`;


if (['development', 'production', 'test'].includes(config.env)) {
    if (fs.existsSync(path.join(__dirname, `${config.env}.js`))) { // eslint-disable-line security/detect-non-literal-fs-filename
        _.merge(config, require(`./${config.env}`)); // eslint-disable-line security/detect-non-literal-require
    }
}


module.exports = config;
fork icon17
star icon1
watch icon8

203
204
205
206
207
208
209
210
211
212
213
214
}


/** ******* */


function init(c) {
  config = _.merge(
    {
      namespace: '',
      debug: {
        prefix: ''
fork icon2
star icon4
watch icon4

+ 14 other calls in file

125
126
127
128
129
130
131
132
133
134
    )
  )
}

// 3. Merge the trees and transform them
const tree = merge({}, ...trees)

// 4. Include tree into rojo configuration
const rojoProject =
  importJson(path.resolve(project.path, 'rojo.json')) || {}
fork icon0
star icon1
watch icon1

+ 2 other calls in file

1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
let fieldType = type;
if (type.extend) {
  // Allow a field type to extend another field type and merge
  // in some differences.
  fieldType = _.cloneDeep(self.fieldTypes[type.extend]);
  _.merge(fieldType, type);
}
// For bc. csv was a bad name for the string converter, but
// we need to accept it, and even keep the property around
// for bc with those extending in sneaky ways
fork icon540
star icon0
watch icon125

348
349
350
351
352
353
354
355
356
357
    return { [parsedTagKey]: parsedTagValue }
  }
  return { [tagName]: tagValue }
})

const parsedTags = _.merge(
  ...(serviceDescription?.tags || []).map((tag) => {
    const [tagKey, tagValue] = tag.toLocaleLowerCase().split(/\s*?:\s*?/)
    return { [tagKey]: tagValue }
  }),
fork icon0
star icon1
watch icon1

+ 3 other calls in file

120
121
122
123
124
125
126
127
128
129
  locals: templatePackage.locals,
};

// Set the default font for each template
if (template.locals.body_font !== undefined) {
  template.locals.body_font = _.merge(
    _.cloneDeep(DEFAULT_FONT),
    template.locals.body_font
  );
}
fork icon69
star icon0
watch icon23

+ 5 other calls in file

8
9
10
11
12
13
14
15
16
17
18
const emitter = require("../../utils/emitter");
const { Timer } = require("../timer");


class HttpSystemTaskNode extends SystemTaskNode {
  static get schema() {
    return _.merge(super.schema, {
      type: "object",
      properties: {
        next: { type: "string" },
        parameters: {
fork icon6
star icon6
watch icon3

+ 2 other calls in file

605
606
607
608
609
610
611
612
613
614
}
if (typeof modelfield !== 'undefined') {
  rslt.splice(rslt.indexOf(modelfield), 1);
  if (!('__REMOVE__' in modelfield)) {
    //oldfield = field, newfield = modelfield
    var newfield = _.merge({}, field, modelfield);
    if(eachItem) eachItem(modelfield, field, newfield);
    rslt.push(newfield);
  }
}
fork icon5
star icon5
watch icon2

+ 2 other calls in file

213
214
215
216
217
218
219
220
221
var keyname = keyfield.name;
var dbtype = _this.getDBType(keyfield);
sql_ptypes.push(dbtype);
sql_params[keyname] = this.DeformatParam(keyfield, keyid, verrors);

verrors = _.merge(verrors, model.xvalidate.Validate('K', sql_params));
if (!_.isEmpty(verrors)) { Helper.GenError(req, res, -2, verrors[''].join('\n')); return; }

var sql = db.sql.Download(_this.jsh, model, fields, keys, datalockqueries);
fork icon5
star icon5
watch icon2

77
78
79
80
81
82
83
84
85
86
87
88
89


    } else {


        return opts.simple
            ? simpleMerged
            : _.merge(simpleMerged, commandLineArgs);


    }
}

fork icon5
star icon2
watch icon1

+ 2 other calls in file

273
274
275
276
277
278
279
280
281
282
  })
],
asyncMiddleware(async function (req, res) {

var surveyRequest = new SurveyRequest()
_.merge(surveyRequest, req.body)

// DO NOT update the record state here. Record state changes should only
// happen in the record state handlers
delete surveyRequest.recordState
fork icon2
star icon2
watch icon8

+ 3 other calls in file

328
329
330
331
332
333
334
335
336
337
  })
],
asyncMiddleware(async function (req, res) {

  var pas = new PriorityAreaSubmission();
  _.merge(pas, req.body);

  const isNew = _.isNil(pas.id);
  if (!isNew) {
    // then check if record is deleted
fork icon2
star icon2
watch icon8

+ 3 other calls in file

Other functions in lodash

Sorted by popularity

function icon

lodash.get is the most popular function in lodash (7670 examples)