GT2/GT2-Android/node_modules/deep-diff/releases/deep-diff-0.1.3.min.js

6 lines
3.3 KiB
JavaScript
Raw Normal View History

/*!
* deep-diff-0.1.3.
* Licensed under the MIT License.
*/
!function(e){"use strict";var t,n,r=[];if(typeof global=="object"&&global){t=global}else if(typeof window!=="undefined"){t=window}else{t={}}n=t.DeepDiff;if(n){r.push(function(){if("undefined"!==typeof n&&t.DeepDiff===h){t.DeepDiff=n;n=e}})}function i(e,t){e.super_=t;e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:false,writable:true,configurable:true}})}function f(e,t){Object.defineProperty(this,"kind",{value:e,enumerable:true});if(t&&t.length){Object.defineProperty(this,"path",{value:t,enumerable:true})}}function u(e,t,n){u.super_.call(this,"E",e);Object.defineProperty(this,"lhs",{value:t,enumerable:true});Object.defineProperty(this,"rhs",{value:n,enumerable:true})}i(u,f);function a(e,t){a.super_.call(this,"N",e);Object.defineProperty(this,"rhs",{value:t,enumerable:true})}i(a,f);function l(e,t){l.super_.call(this,"D",e);Object.defineProperty(this,"lhs",{value:t,enumerable:true})}i(l,f);function o(e,t,n){o.super_.call(this,"A",e);Object.defineProperty(this,"index",{value:t,enumerable:true});Object.defineProperty(this,"item",{value:n,enumerable:true})}i(o,f);function s(e,t,n){var r=e.slice((n||t)+1||e.length);e.length=t<0?e.length+t:t;e.push.apply(e,r);return e}function c(t,n,r,i,f,h){i=i||[];var p=i.slice(0);if(f){p.push(f)}var b=typeof t;var d=typeof n;if(b==="undefined"){if(d!=="undefined"){r(new a(p,n))}}else if(d==="undefined"){r(new l(p,t))}else if(b!==d){r(new u(p,t,n))}else if(b==="object"&&t!=null){h=h||[];if(h.indexOf(t)<0){h.push(t);if(Array.isArray(t)){var v,y=t.length,m=function(e){r(new o(p,v,e))};for(v=0;v<t.length;v++){if(v>=n.length){r(new o(p,v,new l(e,t[v])))}else{c(t[v],n[v],m,[],null,h)}}while(v<n.length){r(new o(p,v,new a(e,n[v++])))}}else{var g=Object.keys(t);var w=Object.keys(n);g.forEach(function(i){var f=w.indexOf(i);if(f>=0){c(t[i],n[i],r,p,i,h);w=s(w,f)}else{c(t[i],e,r,p,i,h)}});w.forEach(function(t){c(e,n[t],r,p,t,h)})}h.length=h.length-1}}else if(t!==n){r(new u(p,t,n))}}function h(t,n,r){r=r||[];c(t,n,function(e){if(e){r.push(e)}});return r.length?r:e}function p(e,t,n){if(n.path&&n.path.length){var r=e[t],i,f=n.path.length-1;for(i=0;i<f;i++){r=r[n.path[i]]}switch(n.kind){case"A":p(r,n.index,n.item);break;case"D":delete r[n.path[i]];break;case"E":case"N":r[n.path[i]]=n.rhs;break}}else{switch(n.kind){case"A":p(e[t],n.index,n.item);break;case"D":e=s(e,t);break;case"E":case"N":e[t]=n.rhs;break}}return e}function b(e,t,n){if(!(n instanceof f)){throw new TypeError("[Object] change must be instanceof Diff")}if(e&&t&&n){var r=e,i,u;u=n.path.length-1;for(i=0;i<u;i++){if(typeof r[n.path[i]]==="undefined"){r[n.path[i]]={}}r=r[n.path[i]]}switch(n.kind){case"A":p(r[n.path[i]],n.index,n.item);break;case"D":delete r[n.path[i]];break;case"E":case"N":r[n.path[i]]=n.rhs;break}}}function d(e,t,n){if(e&&t){var r=function(r){if(!n||n(e,t,r)){b(e,t,r)}};c(e,t,r)}}Object.defineProperties(h,{diff:{value:h,enumerable:true},observableDiff:{value:c,enumerable:true},applyDiff:{value:d,enumerable:true},applyChange:{value:b,enumerable:true},isConflict:{get:function(){return"undefined"!==typeof n},enumerable:true},noConflict:{value:function(){if(r){r.forEach(function(e){e()});r=null}return h},enumerable:true}});if(typeof module!="undefined"&&module&&typeof exports=="object"&&exports&&module.exports===exports){module.exports=h}else{t.DeepDiff=h}}();