Socket
Socket
Sign inDemoInstall

merge

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

merge

(recursive)? merging of (cloned)? objects.


Version published
Weekly downloads
2.2M
decreased by-3.28%
Maintainers
1
Weekly downloads
 
Created

What is merge?

The merge npm package is a utility that allows you to merge multiple objects into one. It is useful when you want to combine configurations, settings, or other data structures in JavaScript. It performs a deep merge by default, meaning that it recursively merges properties of objects, but it can also be configured to perform a shallow merge.

What are merge's main functionalities?

Deep Merge

This feature allows for the deep merging of objects, meaning that nested objects will also be merged together. The code sample demonstrates merging two objects with nested properties.

{"const merge = require('merge');
const object1 = { a: 1, b: { c: 2 } };
const object2 = { b: { d: 3 }, e: 4 };
const mergedObject = merge(object1, object2);
console.log(mergedObject); // Output: { a: 1, b: { c: 2, d: 3 }, e: 4 }"}

Shallow Merge

This feature allows for the shallow merging of objects, which means that it will not recursively merge nested objects. The code sample demonstrates merging two objects without combining the nested properties.

{"const merge = require('merge');
const object1 = { a: 1, b: { c: 2 } };
const object2 = { b: { d: 3 }, e: 4 };
const mergedObject = merge.recursive(false, object1, object2);
console.log(mergedObject); // Output: { a: 1, b: { d: 3 }, e: 4 }"}

Other packages similar to merge

Keywords

FAQs

Package last updated on 22 Feb 2021

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