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

@75lb/deep-merge

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@75lb/deep-merge

Deep-merge the values of one object structure into another

  • 1.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is @75lb/deep-merge?

@75lb/deep-merge is an npm package designed to deeply merge multiple objects into one. It handles nested objects and arrays, providing a robust solution for combining complex data structures.

What are @75lb/deep-merge's main functionalities?

Basic Deep Merge

This feature allows you to merge two objects deeply, combining their properties. Nested objects are merged recursively.

const deepMerge = require('@75lb/deep-merge');
const obj1 = { a: 1, b: { c: 2 } };
const obj2 = { b: { d: 3 } };
const result = deepMerge(obj1, obj2);
console.log(result); // { a: 1, b: { c: 2, d: 3 } }

Merging Arrays

This feature demonstrates how arrays within objects are merged. The arrays are concatenated.

const deepMerge = require('@75lb/deep-merge');
const obj1 = { a: [1, 2, 3] };
const obj2 = { a: [4, 5] };
const result = deepMerge(obj1, obj2);
console.log(result); // { a: [1, 2, 3, 4, 5] }

Custom Merge Function

This feature allows you to provide a custom merge function to control how specific types of values are merged.

const deepMerge = require('@75lb/deep-merge');
const customMerge = (target, source) => Array.isArray(target) ? target.concat(source) : undefined;
const obj1 = { a: [1, 2], b: { c: 3 } };
const obj2 = { a: [3, 4], b: { d: 4 } };
const result = deepMerge(obj1, obj2, customMerge);
console.log(result); // { a: [1, 2, 3, 4], b: { c: 3, d: 4 } }

Other packages similar to @75lb/deep-merge

Keywords

FAQs

Package last updated on 31 Jul 2024

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