Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

browser-interaction-time

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

browser-interaction-time - npm Package Compare versions

Comparing version 1.1.3 to 1.1.4

24

dist/browser-interaction-time.es5.js
var BrowserInteractionTime = /** @class */ (function () {
function BrowserInteractionTime(_a) {
var timeIntervalEllapsedCallbacks = _a.timeIntervalEllapsedCallbacks, absoluteTimeEllapsedCallbacks = _a.absoluteTimeEllapsedCallbacks, checkCallbacksIntervalMs = _a.checkCallbacksIntervalMs, userLeftCallbacks = _a.browserTabInactiveCallbacks, userReturnCallbacks = _a.browserTabActiveCallbacks, idleTimeoutMs = _a.idleTimeoutMs;
var timeIntervalEllapsedCallbacks = _a.timeIntervalEllapsedCallbacks, absoluteTimeEllapsedCallbacks = _a.absoluteTimeEllapsedCallbacks, checkCallbacksIntervalMs = _a.checkCallbacksIntervalMs, browserTabInactiveCallbacks = _a.browserTabInactiveCallbacks, browserTabActiveCallbacks = _a.browserTabActiveCallbacks, idleTimeoutMs = _a.idleTimeoutMs;
var _this = this;
this.onBrowserTabInactive = function () {
// if running pause timer
if (_this.isRunning) {
if (_this.isRunning()) {
_this.stopTimer();
}
_this.browserTabInactiveCallbacks.forEach(function (fn) { return fn(); });
_this.browserTabInactiveCallbacks.forEach(function (fn) {
return fn(_this.getTimeInMilliseconds());
});
};
this.onBrowserTabActive = function () {
// if not running start timer
if (!_this.isRunning) {
if (!_this.isRunning()) {
_this.startTimer();
}
_this.browserTabActiveCallbacks.forEach(function (fn) { return fn(); });
_this.browserTabActiveCallbacks.forEach(function (fn) {
return fn(_this.getTimeInMilliseconds());
});
};

@@ -24,3 +28,3 @@ this.onTimePassed = function () {

if (!pending && timeInMilliseconds <= _this.getTimeInMilliseconds()) {
callback();
callback(_this.getTimeInMilliseconds());
_this.absoluteTimeEllapsedCallbacks[index].pending = true;

@@ -32,3 +36,3 @@ }

if (timeInMilliseconds <= _this.getTimeInMilliseconds()) {
callback();
callback(_this.getTimeInMilliseconds());
_this.timeIntervalEllapsedCallbacks[index].timeInMilliseconds = multiplier(timeInMilliseconds);

@@ -76,3 +80,3 @@ }

var last = _this.times[_this.times.length - 1];
if (last && last.start && last.stop === null) {
if (last && last.stop === null) {
return;

@@ -128,4 +132,4 @@ }

};
this.browserTabActiveCallbacks = userReturnCallbacks;
this.browserTabInactiveCallbacks = userLeftCallbacks;
this.browserTabActiveCallbacks = browserTabActiveCallbacks;
this.browserTabInactiveCallbacks = browserTabInactiveCallbacks;
this.times = [];

@@ -132,0 +136,0 @@ this.timeInMs = 0;

@@ -9,17 +9,21 @@ (function (global, factory) {

function BrowserInteractionTime(_a) {
var timeIntervalEllapsedCallbacks = _a.timeIntervalEllapsedCallbacks, absoluteTimeEllapsedCallbacks = _a.absoluteTimeEllapsedCallbacks, checkCallbacksIntervalMs = _a.checkCallbacksIntervalMs, userLeftCallbacks = _a.browserTabInactiveCallbacks, userReturnCallbacks = _a.browserTabActiveCallbacks, idleTimeoutMs = _a.idleTimeoutMs;
var timeIntervalEllapsedCallbacks = _a.timeIntervalEllapsedCallbacks, absoluteTimeEllapsedCallbacks = _a.absoluteTimeEllapsedCallbacks, checkCallbacksIntervalMs = _a.checkCallbacksIntervalMs, browserTabInactiveCallbacks = _a.browserTabInactiveCallbacks, browserTabActiveCallbacks = _a.browserTabActiveCallbacks, idleTimeoutMs = _a.idleTimeoutMs;
var _this = this;
this.onBrowserTabInactive = function () {
// if running pause timer
if (_this.isRunning) {
if (_this.isRunning()) {
_this.stopTimer();
}
_this.browserTabInactiveCallbacks.forEach(function (fn) { return fn(); });
_this.browserTabInactiveCallbacks.forEach(function (fn) {
return fn(_this.getTimeInMilliseconds());
});
};
this.onBrowserTabActive = function () {
// if not running start timer
if (!_this.isRunning) {
if (!_this.isRunning()) {
_this.startTimer();
}
_this.browserTabActiveCallbacks.forEach(function (fn) { return fn(); });
_this.browserTabActiveCallbacks.forEach(function (fn) {
return fn(_this.getTimeInMilliseconds());
});
};

@@ -31,3 +35,3 @@ this.onTimePassed = function () {

if (!pending && timeInMilliseconds <= _this.getTimeInMilliseconds()) {
callback();
callback(_this.getTimeInMilliseconds());
_this.absoluteTimeEllapsedCallbacks[index].pending = true;

@@ -39,3 +43,3 @@ }

if (timeInMilliseconds <= _this.getTimeInMilliseconds()) {
callback();
callback(_this.getTimeInMilliseconds());
_this.timeIntervalEllapsedCallbacks[index].timeInMilliseconds = multiplier(timeInMilliseconds);

@@ -83,3 +87,3 @@ }

var last = _this.times[_this.times.length - 1];
if (last && last.start && last.stop === null) {
if (last && last.stop === null) {
return;

@@ -135,4 +139,4 @@ }

};
this.browserTabActiveCallbacks = userReturnCallbacks;
this.browserTabInactiveCallbacks = userLeftCallbacks;
this.browserTabActiveCallbacks = browserTabActiveCallbacks;
this.browserTabInactiveCallbacks = browserTabInactiveCallbacks;
this.times = [];

@@ -139,0 +143,0 @@ this.timeInMs = 0;

@@ -5,17 +5,21 @@ "use strict";

function BrowserInteractionTime(_a) {
var timeIntervalEllapsedCallbacks = _a.timeIntervalEllapsedCallbacks, absoluteTimeEllapsedCallbacks = _a.absoluteTimeEllapsedCallbacks, checkCallbacksIntervalMs = _a.checkCallbacksIntervalMs, userLeftCallbacks = _a.browserTabInactiveCallbacks, userReturnCallbacks = _a.browserTabActiveCallbacks, idleTimeoutMs = _a.idleTimeoutMs;
var timeIntervalEllapsedCallbacks = _a.timeIntervalEllapsedCallbacks, absoluteTimeEllapsedCallbacks = _a.absoluteTimeEllapsedCallbacks, checkCallbacksIntervalMs = _a.checkCallbacksIntervalMs, browserTabInactiveCallbacks = _a.browserTabInactiveCallbacks, browserTabActiveCallbacks = _a.browserTabActiveCallbacks, idleTimeoutMs = _a.idleTimeoutMs;
var _this = this;
this.onBrowserTabInactive = function () {
// if running pause timer
if (_this.isRunning) {
if (_this.isRunning()) {
_this.stopTimer();
}
_this.browserTabInactiveCallbacks.forEach(function (fn) { return fn(); });
_this.browserTabInactiveCallbacks.forEach(function (fn) {
return fn(_this.getTimeInMilliseconds());
});
};
this.onBrowserTabActive = function () {
// if not running start timer
if (!_this.isRunning) {
if (!_this.isRunning()) {
_this.startTimer();
}
_this.browserTabActiveCallbacks.forEach(function (fn) { return fn(); });
_this.browserTabActiveCallbacks.forEach(function (fn) {
return fn(_this.getTimeInMilliseconds());
});
};

@@ -27,3 +31,3 @@ this.onTimePassed = function () {

if (!pending && timeInMilliseconds <= _this.getTimeInMilliseconds()) {
callback();
callback(_this.getTimeInMilliseconds());
_this.absoluteTimeEllapsedCallbacks[index].pending = true;

@@ -35,3 +39,3 @@ }

if (timeInMilliseconds <= _this.getTimeInMilliseconds()) {
callback();
callback(_this.getTimeInMilliseconds());
_this.timeIntervalEllapsedCallbacks[index].timeInMilliseconds = multiplier(timeInMilliseconds);

@@ -79,3 +83,3 @@ }

var last = _this.times[_this.times.length - 1];
if (last && last.start && last.stop === null) {
if (last && last.stop === null) {
return;

@@ -131,4 +135,4 @@ }

};
this.browserTabActiveCallbacks = userReturnCallbacks;
this.browserTabInactiveCallbacks = userLeftCallbacks;
this.browserTabActiveCallbacks = browserTabActiveCallbacks;
this.browserTabInactiveCallbacks = browserTabInactiveCallbacks;
this.times = [];

@@ -135,0 +139,0 @@ this.timeInMs = 0;

interface BaseTimeEllapsedCallbackData {
callback: () => void;
callback: (timeInMs: number) => void;
timeInMilliseconds: number;
}
declare type basicCallback = (timeInMs: number) => void;
export interface TimeIntervalEllapsedCallbackData extends BaseTimeEllapsedCallbackData {

@@ -14,4 +15,4 @@ multiplier: (time: number) => number;

absoluteTimeEllapsedCallbacks: AbsoluteTimeEllapsedCallbackData[];
browserTabInactiveCallbacks: Function[];
browserTabActiveCallbacks: Function[];
browserTabInactiveCallbacks: basicCallback[];
browserTabActiveCallbacks: basicCallback[];
pauseOnMouseMovement: boolean;

@@ -36,3 +37,3 @@ pauseOnScroll: boolean;

private absoluteTimeEllapsedCallbacks;
constructor({ timeIntervalEllapsedCallbacks, absoluteTimeEllapsedCallbacks, checkCallbacksIntervalMs, browserTabInactiveCallbacks: userLeftCallbacks, browserTabActiveCallbacks: userReturnCallbacks, idleTimeoutMs }: Settings);
constructor({ timeIntervalEllapsedCallbacks, absoluteTimeEllapsedCallbacks, checkCallbacksIntervalMs, browserTabInactiveCallbacks, browserTabActiveCallbacks, idleTimeoutMs }: Settings);
private onBrowserTabInactive;

@@ -50,4 +51,4 @@ private onBrowserTabActive;

addAbsoluteTimeEllapsedCallback: (absoluteTimeEllapsedCallback: AbsoluteTimeEllapsedCallbackData) => void;
addBrowserTabInactiveCallback: (browserTabInactiveCallback: Function) => void;
addBrowserTabActiveCallback: (browserTabActiveCallback: Function) => void;
addBrowserTabInactiveCallback: (browserTabInactiveCallback: basicCallback) => void;
addBrowserTabActiveCallback: (browserTabActiveCallback: basicCallback) => void;
getTimeInMilliseconds: () => number;

@@ -54,0 +55,0 @@ isRunning: () => boolean;

{
"name": "browser-interaction-time",
"version": "1.1.3",
"version": "1.1.4",
"description": "",

@@ -5,0 +5,0 @@ "keywords": [],

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc