lib/har/viewer/scripts/preview/ref.js

Summary

Maintainability
A
0 mins
Test Coverage
define("preview/ref",["core/lib"],function(e){var t={resolveJson:function(t,n){function p(d,v,m,g,y){var b,w,E=r in d?d[r]:m;E!==undefined&&(E=(i+E).replace(l,"$2$3"));var S=y||d;if(E!==undefined){s&&(d.__id=E),n.schemas&&!(d instanceof Array)&&(w=E.match(/^(.+\/)[^\.\[]*$/))&&(g=n.schemas[w[1]]);if(o[E]&&d instanceof Array==o[E]instanceof Array)S=o[E],delete S.$ref,b=!0;else{var x=g&&g.prototype;x&&(h.prototype=x,S=new h)}o[E]=S,u&&(u[E]=n.time)}var T=g&&g.properties,N=d.length;for(var C in d){if(C==N)break;if(d.hasOwnProperty(C)){w=d[C];var k=T&&T[C];if(k&&k.format=="date-time"&&typeof w=="string")w=e.fromISOString(w);else if(typeof w=="object"&&w&&!(w instanceof Date)){a=w.$ref;if(a){delete d[C];var L=a.replace(/(#)([^\.\[])/,"$1.$2").match(/(^([^\[]*\/)?[^#\.\[]*)#?([\.\[].*)?/);(a=L[1]=="$"||L[1]=="this"||L[1]==""?t:o[(i+L[1]).replace(l,"$2$3")])&&L[3]&&L[3].replace(/(\[([^\]]+)\])|(\.?([^\.\[]+))/g,function(e,t,n,r,i){a=a&&a[n?n.replace(/[\"\'\\]/,""):i]});if(a)w=a;else if(!v){var A;A||f.push(S),A=!0}else w=p(w,!1,w.$ref,k),w._loadObject=n.loader}else v||(w=p(w,f==d,E&&c(E,C),k,S!=d&&typeof S[C]=="object"&&S[C]))}d[C]=w;if(S!=d&&!S.__isDirty){var O=S[C];S[C]=w,b&&w!==O&&!S._loadObject&&!(w instanceof Date&&O instanceof Date&&w.getTime()==O.getTime())&&(typeof w!="function"||typeof O!="function"||w.toString()!=O.toString())&&o.onUpdate&&o.onUpdate(S,C,O,w)}}}if(b){for(C in S)if(!S.__isDirty&&S.hasOwnProperty(C)&&!d.hasOwnProperty(C)&&C!="__id"&&C!="__clientId"&&!(S instanceof Array&&isNaN(C))){o.onUpdate&&C!="_loadObject"&&C!="_idAttr"&&o.onUpdate(S,C,S[C],undefined),delete S[C];while(S instanceof Array&&S.length&&S[S.length-1]===undefined)S.length--}}else o.onLoad&&o.onLoad(S);return S}n=n||{};var r=n.idAttribute||"id",i=n.idPrefix||"",s=n.assignAbsoluteIds,o=n.index||{},u=n.timeStamps,a,f=[],l=/^(.*\/)?(\w+:\/\/)|[^\/\.]+\/\.\.\/|^.*\/(\/)/,c=this._addProp,h=function(){};return t&&typeof t=="object"&&(t=p(t,!1,n.defaultId),p(f,!1)),t},_addProp:function(e,t){return e+(e.match(/#/)?e.length==1?"":".":"#")+t}};return t});