in pytheas-core/src/main/resources/js/jsondiffpatch.js [190:273]
var diff = jdp.diff = function(o, n){
var ntype, otype, nnull, onull, d;
if (o === n) {
return;
}
if ((o !== o) && (n !== n)) {
return; // o and n are both NaN
}
ntype = typeof n;
otype = typeof o;
nnull = n === null;
onull = o === null;
// handle Date objects
if (otype == 'object' && isDate(o)){
otype = 'date';
}
if (ntype == 'object' && isDate(n)){
ntype = 'date';
if (otype == 'date'){
// check if equal dates
if (o.getTime() === n.getTime()){
return;
}
}
}
if (nnull || onull || ntype == 'undefined' || ntype != otype ||
ntype == 'number' ||
otype == 'number' ||
ntype == 'boolean' ||
otype == 'boolean' ||
ntype == 'string' ||
otype == 'string' ||
ntype == 'date' ||
otype == 'date' ||
((ntype === 'object') && (isArray(n) != isArray(o)))) {
// value changed
d = [];
if (typeof o != 'undefined') {
if (typeof n != 'undefined') {
var longText = (ntype == 'string' && otype == 'string' && Math.min(o.length, n.length) > jdp.config.textDiffMinLength);
if (longText && !jdp.config.textDiff) {
diff_match_patch_autoconfig();
}
if (longText && jdp.config.textDiff) {
// get changes form old value to new value as a text diff
d.push(jdp.config.textDiff(o, n), 0, 2);
}
else {
// old value changed to new value
d.push(o);
d.push(n);
}
}
else {
// old value has been removed
d.push(o);
d.push(0, 0);
}
}
else {
// new value is added
d.push(n);
}
return d;
}
else {
if (isArray(n)) {
// diff 2 arrays
if (n._key || o._key) {
return arrayDiffByKey(o, n, n._key || o._key);
}
else {
return arrayDiff(o, n);
}
}
else {
// diff 2 objects
return objectDiff(o, n);
}
}
};