Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lodash.merge

Package Overview
Dependencies
Maintainers
2
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lodash.merge

The Lodash method `_.merge` exported as a module.

  • 4.6.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
31M
decreased by-15.49%
Maintainers
2
Weekly downloads
 
Created

What is lodash.merge?

The lodash.merge npm package is a method provided by lodash, a popular JavaScript utility library. It is used to recursively merge own and inherited enumerable string keyed properties of source objects into the destination object. It's commonly used to combine configurations, defaults, or to merge JSON objects with a deep copy.

What are lodash.merge's main functionalities?

Deep merging of objects

This feature allows for the deep merging of nested objects, combining properties from both source and destination objects.

{"const object = { 'a': [{ 'b': 2 }, { 'd': 4 }] };
const other = { 'a': [{ 'c': 3 }, { 'e': 5 }] };

_.merge(object, other);
// => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }"}

Merging with customizer function

This feature allows users to specify a customizer function that determines how merging is handled. It's useful for custom merge behavior on specific properties.

{"function customizer(objValue, srcValue) {
  if (_.isArray(objValue)) {
    return objValue.concat(srcValue);
  }
}

const object = { 'a': [1], 'b': [2] };
const other = { 'a': [3], 'b': [4] };

_.mergeWith(object, other, customizer);
// => { 'a': [1, 3], 'b': [2, 4] }"}

Other packages similar to lodash.merge

Keywords

FAQs

Package last updated on 10 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc