resourcetiming-compression
Advanced tools
Comparing version 0.1.0 to 0.1.2
{ | ||
"name": "resourcetiming-compression", | ||
"version": "0.1.0", | ||
"version": "0.1.2", | ||
"homepage": "https://github.com/nicjansma/resourcetiming-compression.js", | ||
@@ -5,0 +5,0 @@ "authors": [ |
@@ -1,1 +0,1 @@ | ||
!function(e){"use strict";var t,o;"undefined"!=typeof e&&(t=e,o=t.ResourceTimingDecompression);var r={};r.noConflict=function(){return t.ResourceTimingDecompression=o,r},r.INITIATOR_TYPES={other:0,img:1,link:2,script:3,css:4,xmlhttprequest:5},r.decompressResources=function(e,t){var o=[];t=t||"";for(var r in e)if(e.hasOwnProperty(r)){var s=e[r],n=t+r;if(-1!==n.indexOf("|",n.length-1)&&(n=n.substring(0,n.length-1)),"string"==typeof s)for(var i=s.split("|"),d=0;d<i.length;d++)o.push(this.decodeCompressedResource(i[d],n));else{var c=this.decompressResources(s,n);o=o.concat(c)}}return o},r.getInitiatorTypeFromIndex=function(e){for(var t in this.INITIATOR_TYPES)if(this.INITIATOR_TYPES[t]===e)return t;return"other"},r.decodeCompressedResource=function(e,t){if(!e||!t)return{};for(var o=e[0],r=e.length>1?e.substring(1).split(","):[],s=0;s<r.length;s++)r[s]=""===r[s]?0:parseInt(r[s],36);var n=r.length>=1?r[0]:0,i=r.length<10?n:this.decodeCompressedResourceTimeStamp(r,10,n),d={name:t,initiatorType:this.getInitiatorTypeFromIndex(o),startTime:n,redirectStart:this.decodeCompressedResourceTimeStamp(r,10,n),redirectEnd:this.decodeCompressedResourceTimeStamp(r,9,n),fetchStart:i,domainLookupStart:this.decodeCompressedResourceTimeStamp(r,8,n),domainLookupEnd:this.decodeCompressedResourceTimeStamp(r,7,n),connectStart:this.decodeCompressedResourceTimeStamp(r,6,n),secureConnectionStart:this.decodeCompressedResourceTimeStamp(r,5,n),connectEnd:this.decodeCompressedResourceTimeStamp(r,4,n),requestStart:this.decodeCompressedResourceTimeStamp(r,3,n),responseStart:this.decodeCompressedResourceTimeStamp(r,2,n),responseEnd:this.decodeCompressedResourceTimeStamp(r,1,n)};return d.duration=d.responseEnd>0?d.responseEnd-d.startTime:0,d},r.decodeCompressedResourceTimeStamp=function(e,t,o){return e&&e.length>=t+1&&0!==e[t]?e[t]+o:0},"function"==typeof define&&define.amd?define([],function(){return r}):"undefined"!=typeof module&&module.exports?module.exports=r:"undefined"!=typeof t&&(t.ResourceTimingDecompression=r)}("undefined"!=typeof window?window:void 0); | ||
!function(e){"use strict";var t,o;"undefined"!=typeof e&&(t=e,o=t.ResourceTimingDecompression);var r={};r.noConflict=function(){return t.ResourceTimingDecompression=o,r},r.INITIATOR_TYPES={other:0,img:1,link:2,script:3,css:4,xmlhttprequest:5},r.decompressResources=function(e,t){var o=[];t=t||"";for(var r in e)if(e.hasOwnProperty(r)){var s=e[r],n=t+r;if(-1!==n.indexOf("|",n.length-1)&&(n=n.substring(0,n.length-1)),"string"==typeof s)for(var i=s.split("|"),d=0;d<i.length;d++)o.push(this.decodeCompressedResource(i[d],n));else{var c=this.decompressResources(s,n);o=o.concat(c)}}return o},r.getInitiatorTypeFromIndex=function(e){for(var t in this.INITIATOR_TYPES)if(this.INITIATOR_TYPES[t]===e)return t;return"other"},r.decodeCompressedResource=function(e,t){if(!e||!t)return{};for(var o=parseInt(e[0]),r=e.length>1?e.substring(1).split(","):[],s=0;s<r.length;s++)r[s]=""===r[s]?0:parseInt(r[s],36);var n=r.length>=1?r[0]:0,i=r.length<10?n:this.decodeCompressedResourceTimeStamp(r,9,n),d={name:t,initiatorType:this.getInitiatorTypeFromIndex(o),startTime:n,redirectStart:this.decodeCompressedResourceTimeStamp(r,9,n)>0?n:0,redirectEnd:this.decodeCompressedResourceTimeStamp(r,9,n),fetchStart:i,domainLookupStart:this.decodeCompressedResourceTimeStamp(r,8,n),domainLookupEnd:this.decodeCompressedResourceTimeStamp(r,7,n),connectStart:this.decodeCompressedResourceTimeStamp(r,6,n),secureConnectionStart:this.decodeCompressedResourceTimeStamp(r,5,n),connectEnd:this.decodeCompressedResourceTimeStamp(r,4,n),requestStart:this.decodeCompressedResourceTimeStamp(r,3,n),responseStart:this.decodeCompressedResourceTimeStamp(r,2,n),responseEnd:this.decodeCompressedResourceTimeStamp(r,1,n)};return d.duration=d.responseEnd>0?d.responseEnd-d.startTime:0,d},r.decodeCompressedResourceTimeStamp=function(e,t,o){return e&&e.length>=t+1&&0!==e[t]?e[t]+o:0},"function"==typeof define&&define.amd?define([],function(){return r}):"undefined"!=typeof module&&module.exports?module.exports=r:"undefined"!=typeof t&&(t.ResourceTimingDecompression=r)}("undefined"!=typeof window?window:void 0); |
@@ -6,3 +6,3 @@ { | ||
"author": "Nic Jansma", | ||
"version": "0.1.0", | ||
"version": "0.1.2", | ||
"repository": { | ||
@@ -9,0 +9,0 @@ "type": "git", |
# resourcetiming-compression.js | ||
v0.1.0 | ||
v0.1.2 | ||
@@ -103,2 +103,4 @@ [http://nicj.net](http://nicj.net) | ||
* v0.1.2 - 2015-02-25: Fixed initiatorType parsing | ||
* v0.1.1 - 2015-02-13: Fixed how redirectStart and fetchStart are calculated | ||
* v0.1.0 - 2014-10-17: Initial version |
@@ -398,2 +398,2 @@ // | ||
} | ||
}(typeof(window) !== "undefined" ? window : undefined)); | ||
}(typeof window !== "undefined" ? window : undefined)); |
@@ -119,3 +119,3 @@ // | ||
var initiatorType = data[0]; | ||
var initiatorType = parseInt(data[0]); | ||
var timings = data.length > 1 ? data.substring(1).split(",") : []; | ||
@@ -137,4 +137,4 @@ | ||
// redirect timings are 10th and 11th array values | ||
var fetchStart = timings.length < 10 ? startTime : this.decodeCompressedResourceTimeStamp(timings, 10, startTime); | ||
// fetchStart is either the redirectEnd time, or startTime | ||
var fetchStart = timings.length < 10 ? startTime : this.decodeCompressedResourceTimeStamp(timings, 9, startTime); | ||
@@ -146,3 +146,3 @@ // all others are offset from startTime | ||
startTime: startTime, | ||
redirectStart: this.decodeCompressedResourceTimeStamp(timings, 10, startTime), | ||
redirectStart: this.decodeCompressedResourceTimeStamp(timings, 9, startTime) > 0 ? startTime : 0, | ||
redirectEnd: this.decodeCompressedResourceTimeStamp(timings, 9, startTime), | ||
@@ -203,2 +203,2 @@ fetchStart: fetchStart, | ||
} | ||
}(typeof(window) !== "undefined" ? window : undefined)); | ||
}(typeof window !== "undefined" ? window : undefined)); |
Sorry, the diff of this file is not supported yet
35852
106