Comparing version 0.3.4 to 0.3.5
730
index.js
@@ -1,422 +0,408 @@ | ||
/*! | ||
* deep-diff. | ||
* Licensed under the MIT License. | ||
*/ | ||
;(function(root, factory) { | ||
'use strict'; | ||
if (typeof define === 'function' && define.amd) { | ||
// AMD. Register as an anonymous module. | ||
define([], function() { | ||
return factory(); | ||
}); | ||
} else if (typeof exports === 'object') { | ||
// Node. Does not work with strict CommonJS, but | ||
// only CommonJS-like environments that support module.exports, | ||
// like Node. | ||
module.exports = factory(); | ||
} else { | ||
// Browser globals (root is window) | ||
root.DeepDiff = factory(); | ||
} | ||
}(this, function(undefined) { | ||
'use strict'; | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : | ||
typeof define === 'function' && define.amd ? define(factory) : | ||
(global.DeepDiff = factory()); | ||
}(this, (function () { 'use strict'; | ||
var $scope, conflict, conflictResolution = []; | ||
if (typeof global === 'object' && global) { | ||
$scope = global; | ||
} else if (typeof window !== 'undefined') { | ||
$scope = window; | ||
} else { | ||
$scope = {}; | ||
} | ||
conflict = $scope.DeepDiff; | ||
if (conflict) { | ||
conflictResolution.push( | ||
function() { | ||
if ('undefined' !== typeof conflict && $scope.DeepDiff === accumulateDiff) { | ||
$scope.DeepDiff = conflict; | ||
conflict = undefined; | ||
} | ||
}); | ||
} | ||
// nodejs compatible on server side and in the browser. | ||
function inherits(ctor, superCtor) { | ||
ctor.super_ = superCtor; | ||
ctor.prototype = Object.create(superCtor.prototype, { | ||
constructor: { | ||
value: ctor, | ||
enumerable: false, | ||
writable: true, | ||
configurable: true | ||
var $scope; | ||
var conflict; | ||
var conflictResolution = []; | ||
if (typeof global === 'object' && global) { | ||
$scope = global; | ||
} else if (typeof window !== 'undefined') { | ||
$scope = window; | ||
} else { | ||
$scope = {}; | ||
} | ||
conflict = $scope.DeepDiff; | ||
if (conflict) { | ||
conflictResolution.push( | ||
function() { | ||
if ('undefined' !== typeof conflict && $scope.DeepDiff === accumulateDiff) { | ||
$scope.DeepDiff = conflict; | ||
conflict = undefined; | ||
} | ||
}); | ||
} | ||
} | ||
function Diff(kind, path) { | ||
Object.defineProperty(this, 'kind', { | ||
value: kind, | ||
enumerable: true | ||
}); | ||
if (path && path.length) { | ||
Object.defineProperty(this, 'path', { | ||
value: path, | ||
enumerable: true | ||
}); | ||
// nodejs compatible on server side and in the browser. | ||
function inherits(ctor, superCtor) { | ||
ctor.super_ = superCtor; | ||
ctor.prototype = Object.create(superCtor.prototype, { | ||
constructor: { | ||
value: ctor, | ||
enumerable: false, | ||
writable: true, | ||
configurable: true | ||
} | ||
} | ||
}); | ||
} | ||
function DiffEdit(path, origin, value) { | ||
DiffEdit.super_.call(this, 'E', path); | ||
Object.defineProperty(this, 'lhs', { | ||
value: origin, | ||
function Diff(kind, path) { | ||
Object.defineProperty(this, 'kind', { | ||
value: kind, | ||
enumerable: true | ||
}); | ||
if (path && path.length) { | ||
Object.defineProperty(this, 'path', { | ||
value: path, | ||
enumerable: true | ||
}); | ||
Object.defineProperty(this, 'rhs', { | ||
value: value, | ||
enumerable: true | ||
}); | ||
} | ||
inherits(DiffEdit, Diff); | ||
} | ||
function DiffNew(path, value) { | ||
DiffNew.super_.call(this, 'N', path); | ||
Object.defineProperty(this, 'rhs', { | ||
value: value, | ||
enumerable: true | ||
}); | ||
} | ||
inherits(DiffNew, Diff); | ||
function DiffEdit(path, origin, value) { | ||
DiffEdit.super_.call(this, 'E', path); | ||
Object.defineProperty(this, 'lhs', { | ||
value: origin, | ||
enumerable: true | ||
}); | ||
Object.defineProperty(this, 'rhs', { | ||
value: value, | ||
enumerable: true | ||
}); | ||
} | ||
inherits(DiffEdit, Diff); | ||
function DiffDeleted(path, value) { | ||
DiffDeleted.super_.call(this, 'D', path); | ||
Object.defineProperty(this, 'lhs', { | ||
value: value, | ||
enumerable: true | ||
}); | ||
} | ||
inherits(DiffDeleted, Diff); | ||
function DiffNew(path, value) { | ||
DiffNew.super_.call(this, 'N', path); | ||
Object.defineProperty(this, 'rhs', { | ||
value: value, | ||
enumerable: true | ||
}); | ||
} | ||
inherits(DiffNew, Diff); | ||
function DiffArray(path, index, item) { | ||
DiffArray.super_.call(this, 'A', path); | ||
Object.defineProperty(this, 'index', { | ||
value: index, | ||
enumerable: true | ||
}); | ||
Object.defineProperty(this, 'item', { | ||
value: item, | ||
enumerable: true | ||
}); | ||
} | ||
inherits(DiffArray, Diff); | ||
function DiffDeleted(path, value) { | ||
DiffDeleted.super_.call(this, 'D', path); | ||
Object.defineProperty(this, 'lhs', { | ||
value: value, | ||
enumerable: true | ||
}); | ||
} | ||
inherits(DiffDeleted, Diff); | ||
function arrayRemove(arr, from, to) { | ||
var rest = arr.slice((to || from) + 1 || arr.length); | ||
arr.length = from < 0 ? arr.length + from : from; | ||
arr.push.apply(arr, rest); | ||
return arr; | ||
} | ||
function DiffArray(path, index, item) { | ||
DiffArray.super_.call(this, 'A', path); | ||
Object.defineProperty(this, 'index', { | ||
value: index, | ||
enumerable: true | ||
}); | ||
Object.defineProperty(this, 'item', { | ||
value: item, | ||
enumerable: true | ||
}); | ||
} | ||
inherits(DiffArray, Diff); | ||
function realTypeOf(subject) { | ||
var type = typeof subject; | ||
if (type !== 'object') { | ||
return type; | ||
} | ||
function arrayRemove(arr, from, to) { | ||
var rest = arr.slice((to || from) + 1 || arr.length); | ||
arr.length = from < 0 ? arr.length + from : from; | ||
arr.push.apply(arr, rest); | ||
return arr; | ||
} | ||
if (subject === Math) { | ||
return 'math'; | ||
} else if (subject === null) { | ||
return 'null'; | ||
} else if (Array.isArray(subject)) { | ||
return 'array'; | ||
} else if (Object.prototype.toString.call(subject) === '[object Date]') { | ||
return 'date'; | ||
} else if (typeof subject.toString !== 'undefined' && /^\/.*\//.test(subject.toString())) { | ||
return 'regexp'; | ||
} | ||
return 'object'; | ||
function realTypeOf(subject) { | ||
var type = typeof subject; | ||
if (type !== 'object') { | ||
return type; | ||
} | ||
function deepDiff(lhs, rhs, changes, prefilter, path, key, stack) { | ||
path = path || []; | ||
var currentPath = path.slice(0); | ||
if (typeof key !== 'undefined') { | ||
if (prefilter) { | ||
if (typeof(prefilter) === 'function' && prefilter(currentPath, key)) { return; } | ||
else if (typeof(prefilter) === 'object') { | ||
if (prefilter.prefilter && prefilter.prefilter(currentPath, key)) { return; } | ||
if (prefilter.normalize) { | ||
var alt = prefilter.normalize(currentPath, key, lhs, rhs); | ||
if (alt) { | ||
lhs = alt[0]; | ||
rhs = alt[1]; | ||
} | ||
if (subject === Math) { | ||
return 'math'; | ||
} else if (subject === null) { | ||
return 'null'; | ||
} else if (Array.isArray(subject)) { | ||
return 'array'; | ||
} else if (Object.prototype.toString.call(subject) === '[object Date]') { | ||
return 'date'; | ||
} else if (typeof subject.toString === 'function' && /^\/.*\//.test(subject.toString())) { | ||
return 'regexp'; | ||
} | ||
return 'object'; | ||
} | ||
function deepDiff(lhs, rhs, changes, prefilter, path, key, stack) { | ||
path = path || []; | ||
var currentPath = path.slice(0); | ||
if (typeof key !== 'undefined') { | ||
if (prefilter) { | ||
if (typeof(prefilter) === 'function' && prefilter(currentPath, key)) { return; } | ||
else if (typeof(prefilter) === 'object') { | ||
if (prefilter.prefilter && prefilter.prefilter(currentPath, key)) { return; } | ||
if (prefilter.normalize) { | ||
var alt = prefilter.normalize(currentPath, key, lhs, rhs); | ||
if (alt) { | ||
lhs = alt[0]; | ||
rhs = alt[1]; | ||
} | ||
} | ||
} | ||
currentPath.push(key); | ||
} | ||
currentPath.push(key); | ||
} | ||
// Use string comparison for regexes | ||
if (realTypeOf(lhs) === 'regexp' && realTypeOf(rhs) === 'regexp') { | ||
lhs = lhs.toString(); | ||
rhs = rhs.toString(); | ||
// Use string comparison for regexes | ||
if (realTypeOf(lhs) === 'regexp' && realTypeOf(rhs) === 'regexp') { | ||
lhs = lhs.toString(); | ||
rhs = rhs.toString(); | ||
} | ||
var ltype = typeof lhs; | ||
var rtype = typeof rhs; | ||
if (ltype === 'undefined') { | ||
if (rtype !== 'undefined') { | ||
changes(new DiffNew(currentPath, rhs)); | ||
} | ||
var ltype = typeof lhs; | ||
var rtype = typeof rhs; | ||
if (ltype === 'undefined') { | ||
if (rtype !== 'undefined') { | ||
changes(new DiffNew(currentPath, rhs)); | ||
} | ||
} else if (rtype === 'undefined') { | ||
changes(new DiffDeleted(currentPath, lhs)); | ||
} else if (realTypeOf(lhs) !== realTypeOf(rhs)) { | ||
changes(new DiffEdit(currentPath, lhs, rhs)); | ||
} else if (Object.prototype.toString.call(lhs) === '[object Date]' && Object.prototype.toString.call(rhs) === '[object Date]' && ((lhs - rhs) !== 0)) { | ||
changes(new DiffEdit(currentPath, lhs, rhs)); | ||
} else if (ltype === 'object' && lhs !== null && rhs !== null) { | ||
stack = stack || []; | ||
if (stack.indexOf(lhs) < 0) { | ||
stack.push(lhs); | ||
if (Array.isArray(lhs)) { | ||
var i, len = lhs.length; | ||
for (i = 0; i < lhs.length; i++) { | ||
if (i >= rhs.length) { | ||
changes(new DiffArray(currentPath, i, new DiffDeleted(undefined, lhs[i]))); | ||
} else { | ||
deepDiff(lhs[i], rhs[i], changes, prefilter, currentPath, i, stack); | ||
} | ||
} else if (rtype === 'undefined') { | ||
changes(new DiffDeleted(currentPath, lhs)); | ||
} else if (realTypeOf(lhs) !== realTypeOf(rhs)) { | ||
changes(new DiffEdit(currentPath, lhs, rhs)); | ||
} else if (realTypeOf(lhs) === 'date' && (lhs - rhs) !== 0) { | ||
changes(new DiffEdit(currentPath, lhs, rhs)); | ||
} else if (ltype === 'object' && lhs !== null && rhs !== null) { | ||
stack = stack || []; | ||
if (stack.indexOf(lhs) < 0) { | ||
stack.push(lhs); | ||
if (Array.isArray(lhs)) { | ||
var i, len = lhs.length; | ||
for (i = 0; i < lhs.length; i++) { | ||
if (i >= rhs.length) { | ||
changes(new DiffArray(currentPath, i, new DiffDeleted(undefined, lhs[i]))); | ||
} else { | ||
deepDiff(lhs[i], rhs[i], changes, prefilter, currentPath, i, stack); | ||
} | ||
while (i < rhs.length) { | ||
changes(new DiffArray(currentPath, i, new DiffNew(undefined, rhs[i++]))); | ||
} | ||
while (i < rhs.length) { | ||
changes(new DiffArray(currentPath, i, new DiffNew(undefined, rhs[i++]))); | ||
} | ||
} else { | ||
var akeys = Object.keys(lhs); | ||
var pkeys = Object.keys(rhs); | ||
akeys.forEach(function(k, i) { | ||
var other = pkeys.indexOf(k); | ||
if (other >= 0) { | ||
deepDiff(lhs[k], rhs[k], changes, prefilter, currentPath, k, stack); | ||
pkeys = arrayRemove(pkeys, other); | ||
} else { | ||
deepDiff(lhs[k], undefined, changes, prefilter, currentPath, k, stack); | ||
} | ||
} else { | ||
var akeys = Object.keys(lhs); | ||
var pkeys = Object.keys(rhs); | ||
akeys.forEach(function(k, i) { | ||
var other = pkeys.indexOf(k); | ||
if (other >= 0) { | ||
deepDiff(lhs[k], rhs[k], changes, prefilter, currentPath, k, stack); | ||
pkeys = arrayRemove(pkeys, other); | ||
} else { | ||
deepDiff(lhs[k], undefined, changes, prefilter, currentPath, k, stack); | ||
} | ||
}); | ||
pkeys.forEach(function(k) { | ||
deepDiff(undefined, rhs[k], changes, prefilter, currentPath, k, stack); | ||
}); | ||
} | ||
stack.length = stack.length - 1; | ||
}); | ||
pkeys.forEach(function(k) { | ||
deepDiff(undefined, rhs[k], changes, prefilter, currentPath, k, stack); | ||
}); | ||
} | ||
} else if (lhs !== rhs) { | ||
if (!(ltype === 'number' && isNaN(lhs) && isNaN(rhs))) { | ||
changes(new DiffEdit(currentPath, lhs, rhs)); | ||
} | ||
stack.length = stack.length - 1; | ||
} | ||
} else if (lhs !== rhs) { | ||
if (!(ltype === 'number' && isNaN(lhs) && isNaN(rhs))) { | ||
changes(new DiffEdit(currentPath, lhs, rhs)); | ||
} | ||
} | ||
} | ||
function accumulateDiff(lhs, rhs, prefilter, accum) { | ||
accum = accum || []; | ||
deepDiff(lhs, rhs, | ||
function(diff) { | ||
if (diff) { | ||
accum.push(diff); | ||
} | ||
}, | ||
prefilter); | ||
return (accum.length) ? accum : undefined; | ||
} | ||
function accumulateDiff(lhs, rhs, prefilter, accum) { | ||
accum = accum || []; | ||
deepDiff(lhs, rhs, | ||
function(diff) { | ||
if (diff) { | ||
accum.push(diff); | ||
} | ||
}, | ||
prefilter); | ||
return (accum.length) ? accum : undefined; | ||
} | ||
function applyArrayChange(arr, index, change) { | ||
if (change.path && change.path.length) { | ||
var it = arr[index], | ||
i, u = change.path.length - 1; | ||
for (i = 0; i < u; i++) { | ||
it = it[change.path[i]]; | ||
} | ||
switch (change.kind) { | ||
case 'A': | ||
applyArrayChange(it[change.path[i]], change.index, change.item); | ||
break; | ||
case 'D': | ||
delete it[change.path[i]]; | ||
break; | ||
case 'E': | ||
case 'N': | ||
it[change.path[i]] = change.rhs; | ||
break; | ||
} | ||
} else { | ||
switch (change.kind) { | ||
case 'A': | ||
applyArrayChange(arr[index], change.index, change.item); | ||
break; | ||
case 'D': | ||
arr = arrayRemove(arr, index); | ||
break; | ||
case 'E': | ||
case 'N': | ||
arr[index] = change.rhs; | ||
break; | ||
} | ||
function applyArrayChange(arr, index, change) { | ||
if (change.path && change.path.length) { | ||
var it = arr[index], | ||
i, u = change.path.length - 1; | ||
for (i = 0; i < u; i++) { | ||
it = it[change.path[i]]; | ||
} | ||
return arr; | ||
switch (change.kind) { | ||
case 'A': | ||
applyArrayChange(it[change.path[i]], change.index, change.item); | ||
break; | ||
case 'D': | ||
delete it[change.path[i]]; | ||
break; | ||
case 'E': | ||
case 'N': | ||
it[change.path[i]] = change.rhs; | ||
break; | ||
} | ||
} else { | ||
switch (change.kind) { | ||
case 'A': | ||
applyArrayChange(arr[index], change.index, change.item); | ||
break; | ||
case 'D': | ||
arr = arrayRemove(arr, index); | ||
break; | ||
case 'E': | ||
case 'N': | ||
arr[index] = change.rhs; | ||
break; | ||
} | ||
} | ||
return arr; | ||
} | ||
function applyChange(target, source, change) { | ||
if (target && source && change && change.kind) { | ||
var it = target, | ||
i = -1, | ||
last = change.path ? change.path.length - 1 : 0; | ||
while (++i < last) { | ||
if (typeof it[change.path[i]] === 'undefined') { | ||
it[change.path[i]] = (typeof change.path[i] === 'number') ? [] : {}; | ||
} | ||
it = it[change.path[i]]; | ||
function applyChange(target, source, change) { | ||
if (target && source && change && change.kind) { | ||
var it = target, | ||
i = -1, | ||
last = change.path ? change.path.length - 1 : 0; | ||
while (++i < last) { | ||
if (typeof it[change.path[i]] === 'undefined') { | ||
it[change.path[i]] = (typeof change.path[i] === 'number') ? [] : {}; | ||
} | ||
switch (change.kind) { | ||
case 'A': | ||
applyArrayChange(change.path ? it[change.path[i]] : it, change.index, change.item); | ||
break; | ||
case 'D': | ||
delete it[change.path[i]]; | ||
break; | ||
case 'E': | ||
case 'N': | ||
it[change.path[i]] = change.rhs; | ||
break; | ||
} | ||
it = it[change.path[i]]; | ||
} | ||
switch (change.kind) { | ||
case 'A': | ||
applyArrayChange(change.path ? it[change.path[i]] : it, change.index, change.item); | ||
break; | ||
case 'D': | ||
delete it[change.path[i]]; | ||
break; | ||
case 'E': | ||
case 'N': | ||
it[change.path[i]] = change.rhs; | ||
break; | ||
} | ||
} | ||
} | ||
function revertArrayChange(arr, index, change) { | ||
if (change.path && change.path.length) { | ||
// the structure of the object at the index has changed... | ||
var it = arr[index], | ||
i, u = change.path.length - 1; | ||
for (i = 0; i < u; i++) { | ||
it = it[change.path[i]]; | ||
} | ||
switch (change.kind) { | ||
case 'A': | ||
revertArrayChange(it[change.path[i]], change.index, change.item); | ||
break; | ||
case 'D': | ||
it[change.path[i]] = change.lhs; | ||
break; | ||
case 'E': | ||
it[change.path[i]] = change.lhs; | ||
break; | ||
case 'N': | ||
delete it[change.path[i]]; | ||
break; | ||
} | ||
} else { | ||
// the array item is different... | ||
switch (change.kind) { | ||
case 'A': | ||
revertArrayChange(arr[index], change.index, change.item); | ||
break; | ||
case 'D': | ||
arr[index] = change.lhs; | ||
break; | ||
case 'E': | ||
arr[index] = change.lhs; | ||
break; | ||
case 'N': | ||
arr = arrayRemove(arr, index); | ||
break; | ||
} | ||
function revertArrayChange(arr, index, change) { | ||
if (change.path && change.path.length) { | ||
// the structure of the object at the index has changed... | ||
var it = arr[index], | ||
i, u = change.path.length - 1; | ||
for (i = 0; i < u; i++) { | ||
it = it[change.path[i]]; | ||
} | ||
return arr; | ||
switch (change.kind) { | ||
case 'A': | ||
revertArrayChange(it[change.path[i]], change.index, change.item); | ||
break; | ||
case 'D': | ||
it[change.path[i]] = change.lhs; | ||
break; | ||
case 'E': | ||
it[change.path[i]] = change.lhs; | ||
break; | ||
case 'N': | ||
delete it[change.path[i]]; | ||
break; | ||
} | ||
} else { | ||
// the array item is different... | ||
switch (change.kind) { | ||
case 'A': | ||
revertArrayChange(arr[index], change.index, change.item); | ||
break; | ||
case 'D': | ||
arr[index] = change.lhs; | ||
break; | ||
case 'E': | ||
arr[index] = change.lhs; | ||
break; | ||
case 'N': | ||
arr = arrayRemove(arr, index); | ||
break; | ||
} | ||
} | ||
return arr; | ||
} | ||
function revertChange(target, source, change) { | ||
if (target && source && change && change.kind) { | ||
var it = target, | ||
i, u; | ||
u = change.path.length - 1; | ||
for (i = 0; i < u; i++) { | ||
if (typeof it[change.path[i]] === 'undefined') { | ||
it[change.path[i]] = {}; | ||
} | ||
it = it[change.path[i]]; | ||
function revertChange(target, source, change) { | ||
if (target && source && change && change.kind) { | ||
var it = target, | ||
i, u; | ||
u = change.path.length - 1; | ||
for (i = 0; i < u; i++) { | ||
if (typeof it[change.path[i]] === 'undefined') { | ||
it[change.path[i]] = {}; | ||
} | ||
switch (change.kind) { | ||
case 'A': | ||
// Array was modified... | ||
// it will be an array... | ||
revertArrayChange(it[change.path[i]], change.index, change.item); | ||
break; | ||
case 'D': | ||
// Item was deleted... | ||
it[change.path[i]] = change.lhs; | ||
break; | ||
case 'E': | ||
// Item was edited... | ||
it[change.path[i]] = change.lhs; | ||
break; | ||
case 'N': | ||
// Item is new... | ||
delete it[change.path[i]]; | ||
break; | ||
} | ||
it = it[change.path[i]]; | ||
} | ||
switch (change.kind) { | ||
case 'A': | ||
// Array was modified... | ||
// it will be an array... | ||
revertArrayChange(it[change.path[i]], change.index, change.item); | ||
break; | ||
case 'D': | ||
// Item was deleted... | ||
it[change.path[i]] = change.lhs; | ||
break; | ||
case 'E': | ||
// Item was edited... | ||
it[change.path[i]] = change.lhs; | ||
break; | ||
case 'N': | ||
// Item is new... | ||
delete it[change.path[i]]; | ||
break; | ||
} | ||
} | ||
} | ||
function applyDiff(target, source, filter) { | ||
if (target && source) { | ||
var onChange = function(change) { | ||
if (!filter || filter(target, source, change)) { | ||
applyChange(target, source, change); | ||
} | ||
}; | ||
deepDiff(target, source, onChange); | ||
} | ||
function applyDiff(target, source, filter) { | ||
if (target && source) { | ||
var onChange = function(change) { | ||
if (!filter || filter(target, source, change)) { | ||
applyChange(target, source, change); | ||
} | ||
}; | ||
deepDiff(target, source, onChange); | ||
} | ||
} | ||
Object.defineProperties(accumulateDiff, { | ||
Object.defineProperties(accumulateDiff, { | ||
diff: { | ||
value: accumulateDiff, | ||
enumerable: true | ||
diff: { | ||
value: accumulateDiff, | ||
enumerable: true | ||
}, | ||
observableDiff: { | ||
value: deepDiff, | ||
enumerable: true | ||
}, | ||
applyDiff: { | ||
value: applyDiff, | ||
enumerable: true | ||
}, | ||
applyChange: { | ||
value: applyChange, | ||
enumerable: true | ||
}, | ||
revertChange: { | ||
value: revertChange, | ||
enumerable: true | ||
}, | ||
isConflict: { | ||
value: function() { | ||
return 'undefined' !== typeof conflict; | ||
}, | ||
observableDiff: { | ||
value: deepDiff, | ||
enumerable: true | ||
enumerable: true | ||
}, | ||
noConflict: { | ||
value: function() { | ||
if (conflictResolution) { | ||
conflictResolution.forEach(function(it) { | ||
it(); | ||
}); | ||
conflictResolution = null; | ||
} | ||
return accumulateDiff; | ||
}, | ||
applyDiff: { | ||
value: applyDiff, | ||
enumerable: true | ||
}, | ||
applyChange: { | ||
value: applyChange, | ||
enumerable: true | ||
}, | ||
revertChange: { | ||
value: revertChange, | ||
enumerable: true | ||
}, | ||
isConflict: { | ||
value: function() { | ||
return 'undefined' !== typeof conflict; | ||
}, | ||
enumerable: true | ||
}, | ||
noConflict: { | ||
value: function() { | ||
if (conflictResolution) { | ||
conflictResolution.forEach(function(it) { | ||
it(); | ||
}); | ||
conflictResolution = null; | ||
} | ||
return accumulateDiff; | ||
}, | ||
enumerable: true | ||
} | ||
}); | ||
enumerable: true | ||
} | ||
}); | ||
return accumulateDiff; | ||
})); | ||
return accumulateDiff; | ||
}))); |
{ | ||
"name": "deep-diff", | ||
"description": "Javascript utility for calculating deep difference, capturing changes, and applying changes across objects; for nodejs and the browser.", | ||
"version": "0.3.4", | ||
"version": "0.3.5", | ||
"license": "MIT", | ||
@@ -14,23 +14,31 @@ "keywords": [ | ||
"contributors": [ | ||
"Dan Drinkard <dan.drinkard@gmail.com>", | ||
"Daniel Spangler <daniel.spangler@gmail.com>", | ||
"Denning <denningj@amazon.com>", | ||
"Elad Efrat <elad@iNNU.ORG>", | ||
"Mats Bryntse <mats.dev@bryntum.com>", | ||
"Simen Bekkhus <sbekkhus91@gmail.com>", | ||
"Paul Pflugradt <paulpflugradt@googlemail.com>", | ||
"wooorm <tituswormer@gmail.com>", | ||
"Nicholas Calugar <njcalugar@gmail.com>", | ||
"Paul Pflugradt <paulpflugradt@googlemail.com>", | ||
"Serkan Serttop <serkanserttop@yahoo.com>", | ||
"Simen Bekkhus <sbekkhus91@gmail.com>", | ||
"Tom Ashworth <tashworth@twitter.com>", | ||
"Tom MacWright <tmcw@users.noreply.github.com>", | ||
"Yandell <hyandell@amazon.com>", | ||
"Thiago Santos <thia.mdossantos@gmail.com>", | ||
"Steve Mao <maochenyan@gmail.com>", | ||
"Mats Bryntse <mats.dev@bryntum.com>", | ||
"Phillip Clark <pclark@leisurelink.com>", | ||
"ZauberNerd <zaubernerd@zaubernerd.de>", | ||
"caasi Huang <caasi.igd@gmail.com>", | ||
"ravishivt <javishi@gmail.com>", | ||
"Daniel Spangler <daniel.spangler@gmail.com>", | ||
"Thomas de Barochez <thomas.barochez+github@gmail.com>", | ||
"Morton Fox <github@qslw.com>", | ||
"Amila Welihinda <amilajack@users.noreply.github.com>", | ||
"Will Biddy <willbiddy@gmail.com>", | ||
"icesoar <icesoar@hotmail.com>", | ||
"Serkan Serttop <serkanserttop@yahoo.com>", | ||
"orlando <operri@opentable.com>", | ||
"ravishivt <javishi@gmail.com>", | ||
"wooorm <tituswormer@gmail.com>" | ||
"Tom MacWright <tmcw@users.noreply.github.com>", | ||
"Denning <denningj@amazon.com>", | ||
"Dan Drinkard <dan.drinkard@gmail.com>", | ||
"Elad Efrat <elad@iNNU.ORG>", | ||
"caasi Huang <caasi.igd@gmail.com>", | ||
"Tom Ashworth <tashworth@twitter.com>" | ||
], | ||
"files": [ | ||
"index.js", | ||
"index.es.js", | ||
"releases/" | ||
@@ -43,2 +51,4 @@ ], | ||
"main": "./index.js", | ||
"module": "./index.es.js", | ||
"jsnext:main": "/index.es.js", | ||
"directories": { | ||
@@ -55,2 +65,3 @@ "examples": "./examples", | ||
"mocha": "^2.2.1", | ||
"rollup": "^0.41.6", | ||
"uglifyjs": "^2.4.10" | ||
@@ -60,5 +71,6 @@ }, | ||
"release": "uglifyjs index.js -o releases/deep-diff-$npm_package_version.min.js -r '$,require,exports,module,window,global' -m --comments '/^!/'", | ||
"pretest": "jscs index.js test/ && jshint index.js test/", | ||
"test": "mocha" | ||
"pretest": "jscs index.es.js test/ -e && jshint index.es.js test/", | ||
"test": "mocha", | ||
"build": "rollup index.es.js -f umd -o index.js -n DeepDiff" | ||
} | ||
} |
@@ -1,2 +0,3 @@ | ||
# deep-diff [![Build Status](https://travis-ci.org/flitbit/diff.png?branch=master)](https://travis-ci.org/flitbit/diff) | ||
# deep-diff [![Build Status](https://travis-ci.org/flitbit/diff.png?branch=master)](https://travis-ci.org/flitbit/diff) | ||
[![NPM](https://nodei.co/npm/deep-diff.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/deep-diff/) | ||
@@ -14,4 +15,12 @@ **deep-diff** is a javascript/node.js module providing utility functions for determining the structural differences between objects and includes some utilities for applying differences across objects. | ||
`0.3.5` - 2017-04-23 — Rolled up recent fixes; patches: | ||
* @stevemao — #79, #80: now testing latest version of node4 | ||
* @mortonfox — #85: referencing mocha's new home | ||
* @tdebarochez — #90: fixed error when .toString not a function | ||
* @thiamsantos — #92, #93: changed module system for improved es2015 modules | ||
`0.3.3` - Thanks @SimenB: enabled npm script for release (alternate to the Makefile). Also linting as part of `npm test`. Thanks @joeldenning: Fixed issue #35; diffs of top level arrays now working. | ||
`0.3.3` - Thanks @SimenB: enabled npm script for release (alternate to the Makefile). Also linting as part of `npm test`. Thanks @joeldenning: Fixed issue #35; diffs of top level arrays now working. | ||
`0.3.2` - Resolves #46; support more robust filters by including `lhs` and `rhs` in the filter callback. By @Orlando80 | ||
@@ -42,3 +51,3 @@ | ||
Tests use [mocha](http://visionmedia.github.io/mocha/) and [expect.js](https://github.com/LearnBoost/expect.js/), so if you clone the [github repository](https://github.com/flitbit/json-ptr) you'll need to run: | ||
Tests use [mocha](http://mochajs.org/) and [expect.js](https://github.com/LearnBoost/expect.js/), so if you clone the [github repository](https://github.com/flitbit/json-ptr) you'll need to run: | ||
@@ -73,3 +82,3 @@ ```bash | ||
> Minified, browser release of the current version of the module is under the `releases` folder. | ||
> In a browser, `deep-diff` defines a global variable `DeepDiff`. If there is a conflict in the global namesapce you can restore the conflicting definition and assign `deep-diff` to another variable like this: `var deep = DeepDiff.noConflict();`. | ||
> In a browser, `deep-diff` defines a global variable `DeepDiff`. If there is a conflict in the global namespace you can restore the conflicting definition and assign `deep-diff` to another variable like this: `var deep = DeepDiff.noConflict();`. | ||
@@ -213,3 +222,3 @@ ## Simple Examples | ||
The `diff` function calculates the difference between two objects. In version `0.1.7` you can supply your own `prefilter` function as the 3rd arguement and control which properties are ignored while calculating differences throughout the object graph. | ||
The `diff` function calculates the difference between two objects. In version `0.1.7` you can supply your own `prefilter` function as the 3rd argument and control which properties are ignored while calculating differences throughout the object graph. | ||
@@ -231,6 +240,7 @@ **Arguments** | ||
+ nodejs `4.2.1` | ||
+ nodejs `6` | ||
+ nodejs `5` | ||
+ nodejs `4` | ||
+ nodejs `0.12` | ||
+ nodejs `0.11` | ||
+ nodejs `0.10` | ||
+ nodejs `0.8` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
87926
18
897
242
7