browser-interaction-time
Advanced tools
Comparing version 1.1.2 to 1.1.3
@@ -10,3 +10,2 @@ var BrowserInteractionTime = /** @class */ (function () { | ||
} | ||
console.log('current time inactive is', _this.getTimeInMilliseconds()); | ||
_this.browserTabInactiveCallbacks.forEach(function (fn) { return fn(); }); | ||
@@ -19,3 +18,2 @@ }; | ||
} | ||
console.log('current time active is', _this.getTimeInMilliseconds()); | ||
_this.browserTabActiveCallbacks.forEach(function (fn) { return fn(); }); | ||
@@ -27,3 +25,3 @@ }; | ||
var callback = _a.callback, pending = _a.pending, timeInMilliseconds = _a.timeInMilliseconds; | ||
if (pending && timeInMilliseconds <= _this.getTimeInMilliseconds()) { | ||
if (!pending && timeInMilliseconds <= _this.getTimeInMilliseconds()) { | ||
callback(); | ||
@@ -74,2 +72,3 @@ _this.absoluteTimeEllapsedCallbacks[index].pending = true; | ||
_this.onTimePassed(); | ||
_this.timeInMs += _this.checkCallbacksIntervalMs; | ||
}, _this.checkCallbacksIntervalMs); | ||
@@ -83,3 +82,3 @@ }; | ||
_this.times.push({ | ||
start: new Date(), | ||
start: _this.timeInMs, | ||
stop: null | ||
@@ -93,3 +92,3 @@ }); | ||
} | ||
_this.times[_this.times.length - 1].stop = new Date(); | ||
_this.times[_this.times.length - 1].stop = _this.timeInMs; | ||
_this.running = false; | ||
@@ -111,12 +110,10 @@ }; | ||
return _this.times.reduce(function (acc, current) { | ||
if (current.stop && current.start) { | ||
return acc + (current.stop.getTime() - current.start.getTime()); | ||
if (current.stop) { | ||
acc = acc + (current.stop - current.start); | ||
} | ||
if (!current.stop && current.start) { | ||
var now = new Date(); | ||
return acc + (now.getTime() - current.start.getTime()); | ||
else { | ||
acc = acc + (_this.timeInMs - current.start); | ||
} | ||
return acc; | ||
}, 0); | ||
return 0; | ||
}; | ||
@@ -138,5 +135,6 @@ this.isRunning = function () { | ||
this.times = []; | ||
this.timeInMs = 0; | ||
this.idle = false; | ||
this.currentIdleTimeMs = 0; | ||
this.checkCallbacksIntervalMs = checkCallbacksIntervalMs || 250; | ||
this.checkCallbacksIntervalMs = checkCallbacksIntervalMs || 100; | ||
this.idleTimeoutMs = idleTimeoutMs || 30000; // 30s | ||
@@ -143,0 +141,0 @@ this.running = false; |
@@ -16,3 +16,2 @@ (function (global, factory) { | ||
} | ||
console.log('current time inactive is', _this.getTimeInMilliseconds()); | ||
_this.browserTabInactiveCallbacks.forEach(function (fn) { return fn(); }); | ||
@@ -25,3 +24,2 @@ }; | ||
} | ||
console.log('current time active is', _this.getTimeInMilliseconds()); | ||
_this.browserTabActiveCallbacks.forEach(function (fn) { return fn(); }); | ||
@@ -33,3 +31,3 @@ }; | ||
var callback = _a.callback, pending = _a.pending, timeInMilliseconds = _a.timeInMilliseconds; | ||
if (pending && timeInMilliseconds <= _this.getTimeInMilliseconds()) { | ||
if (!pending && timeInMilliseconds <= _this.getTimeInMilliseconds()) { | ||
callback(); | ||
@@ -80,2 +78,3 @@ _this.absoluteTimeEllapsedCallbacks[index].pending = true; | ||
_this.onTimePassed(); | ||
_this.timeInMs += _this.checkCallbacksIntervalMs; | ||
}, _this.checkCallbacksIntervalMs); | ||
@@ -89,3 +88,3 @@ }; | ||
_this.times.push({ | ||
start: new Date(), | ||
start: _this.timeInMs, | ||
stop: null | ||
@@ -99,3 +98,3 @@ }); | ||
} | ||
_this.times[_this.times.length - 1].stop = new Date(); | ||
_this.times[_this.times.length - 1].stop = _this.timeInMs; | ||
_this.running = false; | ||
@@ -117,12 +116,10 @@ }; | ||
return _this.times.reduce(function (acc, current) { | ||
if (current.stop && current.start) { | ||
return acc + (current.stop.getTime() - current.start.getTime()); | ||
if (current.stop) { | ||
acc = acc + (current.stop - current.start); | ||
} | ||
if (!current.stop && current.start) { | ||
var now = new Date(); | ||
return acc + (now.getTime() - current.start.getTime()); | ||
else { | ||
acc = acc + (_this.timeInMs - current.start); | ||
} | ||
return acc; | ||
}, 0); | ||
return 0; | ||
}; | ||
@@ -144,5 +141,6 @@ this.isRunning = function () { | ||
this.times = []; | ||
this.timeInMs = 0; | ||
this.idle = false; | ||
this.currentIdleTimeMs = 0; | ||
this.checkCallbacksIntervalMs = checkCallbacksIntervalMs || 250; | ||
this.checkCallbacksIntervalMs = checkCallbacksIntervalMs || 100; | ||
this.idleTimeoutMs = idleTimeoutMs || 30000; // 30s | ||
@@ -149,0 +147,0 @@ this.running = false; |
@@ -12,3 +12,2 @@ "use strict"; | ||
} | ||
console.log('current time inactive is', _this.getTimeInMilliseconds()); | ||
_this.browserTabInactiveCallbacks.forEach(function (fn) { return fn(); }); | ||
@@ -21,3 +20,2 @@ }; | ||
} | ||
console.log('current time active is', _this.getTimeInMilliseconds()); | ||
_this.browserTabActiveCallbacks.forEach(function (fn) { return fn(); }); | ||
@@ -29,3 +27,3 @@ }; | ||
var callback = _a.callback, pending = _a.pending, timeInMilliseconds = _a.timeInMilliseconds; | ||
if (pending && timeInMilliseconds <= _this.getTimeInMilliseconds()) { | ||
if (!pending && timeInMilliseconds <= _this.getTimeInMilliseconds()) { | ||
callback(); | ||
@@ -76,2 +74,3 @@ _this.absoluteTimeEllapsedCallbacks[index].pending = true; | ||
_this.onTimePassed(); | ||
_this.timeInMs += _this.checkCallbacksIntervalMs; | ||
}, _this.checkCallbacksIntervalMs); | ||
@@ -85,3 +84,3 @@ }; | ||
_this.times.push({ | ||
start: new Date(), | ||
start: _this.timeInMs, | ||
stop: null | ||
@@ -95,3 +94,3 @@ }); | ||
} | ||
_this.times[_this.times.length - 1].stop = new Date(); | ||
_this.times[_this.times.length - 1].stop = _this.timeInMs; | ||
_this.running = false; | ||
@@ -113,12 +112,10 @@ }; | ||
return _this.times.reduce(function (acc, current) { | ||
if (current.stop && current.start) { | ||
return acc + (current.stop.getTime() - current.start.getTime()); | ||
if (current.stop) { | ||
acc = acc + (current.stop - current.start); | ||
} | ||
if (!current.stop && current.start) { | ||
var now = new Date(); | ||
return acc + (now.getTime() - current.start.getTime()); | ||
else { | ||
acc = acc + (_this.timeInMs - current.start); | ||
} | ||
return acc; | ||
}, 0); | ||
return 0; | ||
}; | ||
@@ -140,5 +137,6 @@ this.isRunning = function () { | ||
this.times = []; | ||
this.timeInMs = 0; | ||
this.idle = false; | ||
this.currentIdleTimeMs = 0; | ||
this.checkCallbacksIntervalMs = checkCallbacksIntervalMs || 250; | ||
this.checkCallbacksIntervalMs = checkCallbacksIntervalMs || 100; | ||
this.idleTimeoutMs = idleTimeoutMs || 30000; // 30s | ||
@@ -145,0 +143,0 @@ this.running = false; |
@@ -19,3 +19,3 @@ interface BaseTimeEllapsedCallbackData { | ||
idleTimeoutMs: number; | ||
checkCallbacksIntervalMs: number; | ||
checkCallbacksIntervalMs?: number; | ||
} | ||
@@ -28,2 +28,3 @@ export default class BrowserInteractionTime { | ||
private currentIdleTimeMs; | ||
private timeInMs; | ||
private checkCallbacksIntervalMs; | ||
@@ -30,0 +31,0 @@ private idle; |
{ | ||
"name": "browser-interaction-time", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "", | ||
@@ -48,2 +48,3 @@ "keywords": [], | ||
"jest": { | ||
"setupTestFrameworkScriptFile": "jest-extended", | ||
"transform": { | ||
@@ -126,3 +127,6 @@ ".(ts|tsx)": "<rootDir>/node_modules/ts-jest/preprocessor.js" | ||
} | ||
}, | ||
"dependencies": { | ||
"jest-extended": "^0.11.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
60517
1
494
+ Addedjest-extended@^0.11.0
+ Added@babel/code-frame@7.26.2(transitive)
+ Added@babel/helper-validator-identifier@7.25.9(transitive)
+ Added@jest/console@24.9.0(transitive)
+ Added@jest/source-map@24.9.0(transitive)
+ Added@jest/test-result@24.9.0(transitive)
+ Added@jest/types@24.9.0(transitive)
+ Added@types/istanbul-lib-coverage@2.0.6(transitive)
+ Added@types/istanbul-lib-report@3.0.3(transitive)
+ Added@types/istanbul-reports@1.1.2(transitive)
+ Added@types/stack-utils@1.0.1(transitive)
+ Added@types/yargs@13.0.12(transitive)
+ Added@types/yargs-parser@21.0.3(transitive)
+ Addedansi-regex@3.0.14.1.1(transitive)
+ Addedansi-styles@3.2.1(transitive)
+ Addedarr-diff@4.0.0(transitive)
+ Addedarr-flatten@1.1.0(transitive)
+ Addedarr-union@3.1.0(transitive)
+ Addedarray-unique@0.3.2(transitive)
+ Addedassign-symbols@1.0.0(transitive)
+ Addedatob@2.1.2(transitive)
+ Addedbase@0.11.2(transitive)
+ Addedbraces@2.3.2(transitive)
+ Addedcache-base@1.0.1(transitive)
+ Addedcallsites@3.1.0(transitive)
+ Addedchalk@2.4.2(transitive)
+ Addedclass-utils@0.3.6(transitive)
+ Addedcollection-visit@1.0.0(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addedcomponent-emitter@1.3.1(transitive)
+ Addedcopy-descriptor@0.1.1(transitive)
+ Addeddebug@2.6.9(transitive)
+ Addeddecode-uri-component@0.2.2(transitive)
+ Addeddefine-property@0.2.51.0.02.0.2(transitive)
+ Addeddiff-sequences@24.9.0(transitive)
+ Addedescape-string-regexp@1.0.52.0.0(transitive)
+ Addedexpand-brackets@2.1.4(transitive)
+ Addedexpect@24.9.0(transitive)
+ Addedextend-shallow@2.0.13.0.2(transitive)
+ Addedextglob@2.0.4(transitive)
+ Addedfill-range@4.0.0(transitive)
+ Addedfor-in@1.0.2(transitive)
+ Addedfragment-cache@0.2.1(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedget-value@2.0.6(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedhas-flag@3.0.0(transitive)
+ Addedhas-value@0.3.11.0.0(transitive)
+ Addedhas-values@0.1.41.0.0(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedis-accessor-descriptor@1.0.1(transitive)
+ Addedis-buffer@1.1.6(transitive)
+ Addedis-data-descriptor@1.0.1(transitive)
+ Addedis-descriptor@0.1.71.0.3(transitive)
+ Addedis-extendable@0.1.11.0.1(transitive)
+ Addedis-number@3.0.0(transitive)
+ Addedis-plain-object@2.0.4(transitive)
+ Addedis-windows@1.0.2(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedisobject@2.1.03.0.1(transitive)
+ Addedjest-diff@24.9.0(transitive)
+ Addedjest-extended@0.11.5(transitive)
+ Addedjest-get-type@22.4.324.9.0(transitive)
+ Addedjest-matcher-utils@22.4.324.9.0(transitive)
+ Addedjest-message-util@24.9.0(transitive)
+ Addedjest-regex-util@24.9.0(transitive)
+ Addedjs-tokens@4.0.0(transitive)
+ Addedkind-of@3.2.24.0.06.0.3(transitive)
+ Addedmap-cache@0.2.2(transitive)
+ Addedmap-visit@1.0.0(transitive)
+ Addedmicromatch@3.1.10(transitive)
+ Addedmixin-deep@1.3.2(transitive)
+ Addedms@2.0.0(transitive)
+ Addednanomatch@1.2.13(transitive)
+ Addedobject-copy@0.1.0(transitive)
+ Addedobject-visit@1.0.1(transitive)
+ Addedobject.pick@1.3.0(transitive)
+ Addedpascalcase@0.1.1(transitive)
+ Addedpicocolors@1.1.1(transitive)
+ Addedposix-character-classes@0.1.1(transitive)
+ Addedpretty-format@22.4.324.9.0(transitive)
+ Addedreact-is@16.13.1(transitive)
+ Addedregex-not@1.0.2(transitive)
+ Addedrepeat-element@1.1.4(transitive)
+ Addedrepeat-string@1.6.1(transitive)
+ Addedresolve-url@0.2.1(transitive)
+ Addedret@0.1.15(transitive)
+ Addedsafe-regex@1.1.0(transitive)
+ Addedset-value@2.0.1(transitive)
+ Addedslash@2.0.0(transitive)
+ Addedsnapdragon@0.8.2(transitive)
+ Addedsnapdragon-node@2.1.1(transitive)
+ Addedsnapdragon-util@3.0.1(transitive)
+ Addedsource-map@0.5.70.6.1(transitive)
+ Addedsource-map-resolve@0.5.3(transitive)
+ Addedsource-map-url@0.4.1(transitive)
+ Addedsplit-string@3.1.0(transitive)
+ Addedstack-utils@1.0.5(transitive)
+ Addedstatic-extend@0.1.2(transitive)
+ Addedsupports-color@5.5.0(transitive)
+ Addedto-object-path@0.3.0(transitive)
+ Addedto-regex@3.0.2(transitive)
+ Addedto-regex-range@2.1.1(transitive)
+ Addedunion-value@1.0.1(transitive)
+ Addedunset-value@1.0.0(transitive)
+ Addedurix@0.1.0(transitive)
+ Addeduse@3.1.1(transitive)