1. merge
(recursive)? merging of (cloned)? objects.
merge
Package: merge
Created by: yeikos
Last modified: Tue, 19 Sep 2023 22:57:54 GMT
Version: 2.1.1
License: MIT
Downloads: 8,903,524
Repository: https://github.com/yeikos/js.merge

Install

npm install merge
yarn add merge

Merge

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

Install

Node.js

 npm i merge
 import merge from 'merge'

Browser

 <script src="https://cdn.jsdelivr.net/gh/yeikos/js.merge/dist/merge.browser.min.js"></script>
 window.merge

API

 merge(clone: boolean, ...items: Object[])
merge(...items: Object[])
merge.recursive(clone: boolean, ...items: Object[])
merge.recursive(...items: Object[])

Examples

 
// Merge 

{
	var objectA = {} 

	merge(objectA, 
		{ value: 1 }, 
		{ str: 'hello world' }
	)

	var objectB = merge(true, objectA, 
		{ value: 2 }
	)

	objectA // { value: 1, str: 'hello world' }
	objectB // { value: 2, str: 'hello world' }
}

// Recursive merge

{
	var objectA = {}

	merge.recursive(objectA, 
		{ level: { value: 1 } },
		{ level: { str: 'hello world' } }
	)
	var objectB = merge.recursive(true, objectA, 
		{ level: { value: 2 } }
	)

	objectA.level // { value: 1, str: 'hello world' }
	objectB.level // { value: 2, str: 'hello world' }
}

Test

Node.js

 npm test

Browser

./dist/merge.browser.test.html

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin