merge
NodeJS Merge is used to merge multiple objects into one object.
Last updated 13 years ago by yeikos .
Original npm · Tarball · package.json
$ gnpm install merge 
SYNC missed versions from official npm registry.

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

Current Tags

  • 2.1.1                                ...           latest (4 years ago)

9 Versions

  • 2.1.1                                ...           4 years ago
  • 2.1.0                                ...           4 years ago
  • 1.2.1                                ...           6 years ago
  • 1.2.0                                ...           10 years ago
  • 1.1.3                                ...           11 years ago
  • 1.1.2                                ...           11 years ago
  • 1.1.1                                ...           12 years ago
  • 1.1.0                                ...           12 years ago
  • 1.0.0                                ...           13 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (0)
None

Copyright 2013 - present © cnpmjs.org | Home |