Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactors var into let/const #70

Merged
merged 2 commits into from
Mar 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 30 additions & 28 deletions build/UserALEWebExtension/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,34 +72,36 @@ var ADD_LOG = prefix + 'ADD_LOG';
* @return {timeStampScale~tsScaler} The timestamp normalizing function.
*/
function timeStampScale(e) {
if (e.timeStamp && e.timeStamp > 0) {
var delta = Date.now() - e.timeStamp;
/**
* Returns a timestamp depending on various browser quirks.
* @param {?Number} ts A timestamp to use for normalization.
* @return {Number} A normalized timestamp.
*/
var tsScaler;

if (delta < 0) {
tsScaler = function () {
return e.timeStamp / 1000;
};
} else if (delta > e.timeStamp) {
var navStart = performance.timing.navigationStart;
tsScaler = function (ts) {
return ts + navStart;
};
let tsScaler;
if (e.timeStamp && e.timeStamp > 0) {
const delta = Date.now() - e.timeStamp;
/**
* Returns a timestamp depending on various browser quirks.
* @param {?Number} ts A timestamp to use for normalization.
* @return {Number} A normalized timestamp.
*/

if (delta < 0) {
tsScaler = function () {
return e.timeStamp / 1000;
};
} else if (delta > e.timeStamp) {
const navStart = performance.timing.navigationStart;
tsScaler = function (ts) {
return ts + navStart;
};
} else {
tsScaler = function (ts) {
return ts;
};
}
} else {
tsScaler = function (ts) {
return ts;
};
tsScaler = function () {
return Date.now();
};
}
} else {
tsScaler = function () { return Date.now(); };
}

return tsScaler;
return tsScaler;
}

var __spreadArrays = (undefined && undefined.__spreadArrays) || function () {
Expand Down Expand Up @@ -348,7 +350,7 @@ function extractTimeFields(timeStamp) {
* limitations under the License.
*/

var sendIntervalId = null;
let sendIntervalId = null;

/**
* Initializes the log queue processors.
Expand Down Expand Up @@ -417,10 +419,10 @@ function sendOnClose(logs, config) {

// @todo expose config object to sendLogs replate url with config.url
function sendLogs(logs, config, retries) {
var req = new XMLHttpRequest();
const req = new XMLHttpRequest();

// @todo setRequestHeader for Auth
var data = JSON.stringify(logs);
const data = JSON.stringify(logs);

req.open('POST', config.url);
if (config.authHeader) {
Expand Down
Loading