We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can specify which array fields will be replaced (instead of concatenated with union). Few lines in code and all tests working.
union
module.exports = function mergeDeep(orig, objects, notUnionParams) {
if (isObject(val) || Array.isArray(val)) { merge(target, val, notUnionParams); }
function merge(target, obj, notUnionParams) { var notUnion = false;
if((notUnionParams !== undefined) && (notUnionParams.length > 0) && ((notUnionParams.indexOf(key) > -1) || (notUnionParams == key))){ notUnion = true; }
if (isObject(newVal) && isObject(oldVal)) { target[key] = merge(newVal, oldVal, notUnionParams); } else if (Array.isArray(newVal)) { if(notUnion){ target[key] = union([], newVal); } else { target[key] = union([], newVal, oldVal); } } else { target[key] = clone(oldVal); }
And the test
it('should correctly use not union property', function() { var obj1 = {a: { "a": [{ 1: 1,2: 2 }] }}; var obj2 = {a: { "a": [{ 1: 2,2: 3 }] }}; var actual = merge(obj1, obj2, ["a"]); console.log(actual.a); assert.deepEqual(actual.a, { a: [{ 1:1,2:2 }] }); });
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Can specify which array fields will be replaced (instead of concatenated with
union
). Few lines in code and all tests working.module.exports = function mergeDeep(orig, objects, notUnionParams) {
And the test
The text was updated successfully, but these errors were encountered: