Comparing version
@@ -241,9 +241,16 @@ | ||
function applyPush(obj, push) { | ||
(function exec(path, push) { | ||
(function exec(path, pull) { | ||
for(var prop in push) { | ||
var subPath = path && path + '.' + prop || prop; | ||
if(push[prop].$each) { | ||
push[prop] = push[prop].$each; | ||
} | ||
if(getDeltaType(push[prop]) == 'object') { | ||
exec(subPath, push[prop]); | ||
} else if(prop == '$each') { | ||
var arr = traverse(path, obj); | ||
} | ||
else if(getDeltaType(push[prop]) == 'array') { | ||
var arr = traverse(subPath, obj); | ||
for(var i = 0; i < push[prop].length; i += 1) { | ||
@@ -263,18 +270,22 @@ arr.push(push[prop][i]); | ||
for(var prop in pull) { | ||
var subPath = path && path + '.' + prop || prop; | ||
var subPath = path && path + '.' + prop || prop; | ||
if(pull[prop].$each) { | ||
pull[prop] = pull[prop].$each; | ||
} | ||
if(getDeltaType(pull[prop]) == 'object') { | ||
exec(subPath, pull[prop]); | ||
} | ||
} | ||
else if(getDeltaType(pull[prop]) == 'array') { | ||
var arr = traverse(path, obj); | ||
var arr = traverse(subPath, obj); | ||
for(var i = 0; i < pull[prop].length; i += 1) { | ||
arr.splice(arr.indexOf(pull[prop][i]), 1); | ||
var index = arr.indexOf(pull[prop][i]); | ||
if(index > -1) { arr.splice(index, 1); } | ||
} | ||
} | ||
else { | ||
} else { | ||
var arr = traverse(subPath, obj); | ||
arr.splice(arr.indexOf(pull[prop]), 1); | ||
var index = arr.indexOf(pull[prop]); | ||
if(index > -1) { arr.splice(index, 1); } | ||
} | ||
@@ -281,0 +292,0 @@ } |
{ | ||
"name": "primitive", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./lib/primitive.js", |
@@ -134,4 +134,6 @@ | ||
it('returns the delta if it does not contain delta operators', function() { | ||
var o = {}; | ||
var d = {}; | ||
delta.apply({}, d).should.equal(d); | ||
delta.apply(o, d); | ||
o.should.eql(d); | ||
}); | ||
@@ -161,4 +163,4 @@ | ||
for(var i = 0; i < testCases.length; i += 1) { | ||
var d = delta.apply(testCases[i][0], testCases[i][1]); | ||
d.should.eql(testCases[i][2]); | ||
delta.apply(testCases[i][0], testCases[i][1]); | ||
testCases[i][0].should.eql(testCases[i][2]); | ||
} | ||
@@ -176,4 +178,4 @@ }); | ||
for(var i = 0; i < testCases.length; i += 1) { | ||
var d = delta.apply(testCases[i][0], testCases[i][1]); | ||
d.should.eql(testCases[i][2]); | ||
delta.apply(testCases[i][0], testCases[i][1]); | ||
testCases[i][0].should.eql(testCases[i][2]); | ||
} | ||
@@ -190,4 +192,4 @@ }); | ||
for(var i = 0; i < testCases.length; i += 1) { | ||
var d = delta.apply(testCases[i][0], testCases[i][1]); | ||
d.should.eql(testCases[i][2]); | ||
delta.apply(testCases[i][0], testCases[i][1]); | ||
testCases[i][0].should.eql(testCases[i][2]); | ||
} | ||
@@ -204,6 +206,6 @@ }); | ||
for(var i = 0; i < testCases.length; i += 1) { | ||
var d = delta.apply(testCases[i][0], testCases[i][1]); | ||
d.should.eql(testCases[i][2]); | ||
delta.apply(testCases[i][0], testCases[i][1]); | ||
testCases[i][0].should.eql(testCases[i][2]); | ||
} | ||
}); | ||
}); |
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
29659
1.32%25
4.17%935
1.08%1
-50%5
Infinity%