Socket
Socket
Sign inDemoInstall

@types/lodash.merge

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/lodash.merge

TypeScript definitions for lodash.merge


Version published
Maintainers
1
Created

What is @types/lodash.merge?

@types/lodash.merge is a TypeScript type definition package for the lodash.merge function, which is part of the Lodash library. Lodash is a popular utility library that provides a wide range of functions for common programming tasks, including object manipulation, array manipulation, and more. The lodash.merge function specifically is used to merge objects, combining their properties recursively.

What are @types/lodash.merge's main functionalities?

Merging Objects

This feature allows you to merge two or more objects recursively. The properties of the source objects are merged into the destination object. If a property at the same key is an object in both source and destination, they are merged recursively.

const _ = require('lodash');
const object1 = { a: 1, b: { c: 2 } };
const object2 = { b: { d: 3 } };
const result = _.merge(object1, object2);
console.log(result); // { a: 1, b: { c: 2, d: 3 } }

Merging Arrays

When merging arrays, lodash.merge will replace the elements of the array in the destination object with the elements of the array in the source object at the same index.

const _ = require('lodash');
const object1 = { a: [1, 2, 3] };
const object2 = { a: [4, 5] };
const result = _.merge(object1, object2);
console.log(result); // { a: [4, 5, 3] }

Merging with Customizer

This feature allows you to provide a customizer function to control how the merge is performed. In this example, the customizer function concatenates arrays instead of replacing them.

const _ = require('lodash');
const object1 = { a: [1, 2, 3] };
const object2 = { a: [4, 5] };
const customizer = (objValue, srcValue) => {
  if (Array.isArray(objValue)) {
    return objValue.concat(srcValue);
  }
};
const result = _.mergeWith(object1, object2, customizer);
console.log(result); // { a: [1, 2, 3, 4, 5] }

Other packages similar to @types/lodash.merge

FAQs

Package last updated on 18 Apr 2022

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc