GT2/GT2-iOS/node_modules/deep-diff/releases/deep-diff-0.1.5.min.js

6 lines
3.4 KiB
JavaScript

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