-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.min.js
1 lines (1 loc) · 2.76 KB
/
index.min.js
1
!function(){"use strict";var e=Array.isArray||(Array.isArray=function(e){return""+e!==e&&"[object Array]"==={}.toString.call(e)}),t=[].indexOf||function(e){var t=this.length>>>0,r=Number(arguments[1])||0;for((r=r<0?Math.ceil(r):Math.floor(r))<0&&(r+=t);r<t;r++)if(r in this&&this[r]===e)return r;return-1};function r(t,r){var n={};if(function t(r,i){if(Object(r)!==r)n[i]=r;else if(e(r)){for(var o=0,f=r.length;o<f;o++)t(r[o],i?i+"."+o:""+o);0===f&&(n[i]=[])}else{var u=!0;for(var l in r)u=!1,t(r[l],i?i+"."+l:l);u&&(n[i]={})}}(t,""),r){for(var i,o={},f=Object.keys(n).sort(),u=0;u<f.length;u++)o[i=f[u]]=n[i];return o}return n}function n(r){if(Object(r)!==r||e(r))return r;var n,i,o,f,u,l={};for(var c in r){n=l,i="",f=0;do{o=t.call(c,".",f),u=c.substring(f,~o?o:void 0),["__proto__","prototype","constructor"].includes(i)||(n=n[i]||(n[i]=isNaN(parseInt(u))?{}:[])),i=u,f=o+1}while(o>=0);n[i]=r[c]}return l[""]}var i="~",o="\\x"+("0"+i.charCodeAt(0).toString(16)).slice(-2),f=new RegExp(o,"g");function u(e){var r,n=[],u=[e],l=[e],c=[i],a=e,d=1;return function(e,s){return""!==e&&(a!==this&&(r=d-t.call(u,this)-1,d-=r,u.splice(d,u.length),n.splice(d-1,n.length),a=this),"object"==typeof s&&s&&(~t.call(u,s)||u.push(a=s),d=u.length,(r=t.call(l,s))<0?(r=l.push(s)-1,n.push((""+e).replace(f,o)),c[r]=i+n.join(i)):s=c[r])),s}}function l(e,t){return t?JSON.stringify(e,u(e)):JSON.parse(JSON.stringify(e,u(e)))}var c={unflatten:n,flatten:r,accessProperty:function(e,t){var r,n;for("string"==typeof e&&(e=e.split(".")),t=t||("undefined"!=typeof window?window:global),r=0;r<e.length;r++){if(n=e[r],!t||t&&!t.hasOwnProperty(n))return;t=t[n]}return t},discardCircular:l,filterValue:function(i,o,f){i=r(i=l(i));var u,c={},a=e(o);for(var d in i)u=i[d],(a&&~t.call(o,u)||i[d]===o)&&(c[d]=u);return f?c:n(c)},downloadStringified:function(e,t){var r=JSON.stringify(e,null,t||2);if("undefined"!=typeof document){var n=new Blob([r],{type:"text/plain"}),i=document.createElement("a");if("undefined"!=typeof Blob&&"function"==typeof URL.createObjectURL&&void 0!==i.download)return i.href=URL.createObjectURL(n),i.download="object.txt",void i.click()}return r},areObjectsEqual:function(e,t,n){var i,o;for(n||(n=[]),e=r(e=l(e),!0),t=r(t=l(t),!0),i=0;i<n.length;i++)delete e[o=n[i]],delete t[o];return JSON.stringify(e)===JSON.stringify(t)},getObjectsDiff:function(t,i,o,f){t=r(t=l(t),!!o),i=r(i=l(i),!!o);var u,c,a,d,s={},p=Object.keys(t),h=Object.keys(i);for(u=0;u<h.length;u++)(a=t[c=h[u]])===i[c]||e(d=a)&&0===d.length||(s[c]=i[c]);for(u=0;u<p.length;u++)void 0===i[c=p[u]]&&(s[c]="{deleted}");if(f)return s;var v=n(s);return void 0===v?{}:v}};"undefined"!=typeof module&&void 0!==module.exports?module.exports=c:"undefined"!=typeof document&&("function"==typeof define&&define.amd?define([],(function(){return c})):window.NestedObjectsUtil=c)}();