New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

object-merge

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

object-merge - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

2

browser/tests/object-merge.test.js

@@ -54,2 +54,3 @@ /*

func2.wee = 'wee';
func2.obj = {b:'b'};
func2.obj2 = {a:'a'};

@@ -60,2 +61,3 @@ var out = objectMerge(func, func2);

expect(out.obj.a).toEqual('a');
expect(out.obj.b).toEqual('b');
expect(out.obj2.a).toEqual('a');

@@ -62,0 +64,0 @@ expect(out.obj === func.obj).toEqual(false);

2

package.json
{
"name": "object-merge",
"version": "2.1.0",
"version": "2.2.0",
"description": "Merges JavaScript objects recursively without altering the objects merged.",

@@ -5,0 +5,0 @@ "main": "./src/object-merge.js",

@@ -63,6 +63,40 @@ # object-merge

Merging arrays is not the same as `concat`. When they're merged the arrays are
handled as objects. This means that indexes are object properties with numeric
names. Merging `['a']` with `['b']` will give you `['b']` because the two
arrays both have a property `0` and the last one in overrides the first.
However, merging `arr1['a', 'b']` with `arr2[1] = 'override'` will give you
`['a', 'override']` because `arr1` has properties `0` and `1`, while `arr2`
only has the property `1` which overrides `arr1[1]` in the output.
Merging functions will cause the output function to be a clone of the last
function merged and it will have all the properties of the merged functions
recursively merged together. So something like:
```
var func = function () {
return null;
};
var func2 = function () {
return 'hello';
};
func.wohoo = 'wohoo';
func.obj = {a:'a'};
func2.wee = 'wee';
func2.obj = {b:'b'};
func2.obj2 = {a:'a'};
var out = objectMerge(func, func2);
```
will give you a function `out` that is a clone of `func2`'s function definition
but has the properties: `wohoo`, `obj`, `wee`, and `obj2`. `out.obj` will have
the properties `a` and `b` because the properties of `func` and `func2` are
merged recursively.
See the tests in `browser/tests` for more examples and expected outputs.
In the browser, include `./browser/object-merge_web.js` in your page.
`objectMerge` will be available in your page.
For full documentation see the docs folder. For examples see the example folder.
For full documentation see the docs folder.

@@ -77,2 +111,4 @@ ## Tests

There are also browser tests available in the `browser` directory.
## Hacking

@@ -92,4 +128,2 @@

Matthew Kastor
atropa
matthewkastor@gmail.com

@@ -96,0 +130,0 @@ https://plus.google.com/100898583798552211130

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