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

jsperformance

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsperformance - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

130

index.js

@@ -77,59 +77,82 @@

WebPerformance.prototype.addEvents = function(type) {
WebPerformance.prototype.addEachEvents = function(evts) {
var self = this;
return function (evts) {
if (typeof evts === 'string') {
var events = [evts] || ['hashchange'];
}
else if (Object.prototype.toString.call(evts) === '[object Array]') {
var events = evts;
}
for (var i = 0; i < events.length; i++) {
(function(eventName) {
var eventCallback = function(e) {
var e = e || window.event;
var eventHookTime = 0;
var timeAfterEvent = function(time) {
eventHookTime = eventHookTime + time;
};
self.on('executing', timeAfterEvent);
window.removeEventListener(eventName, eventCallback);
setTimeout(function() {
if (type === 'slow' && eventHookTime > self.slowStandard) {
self.trigger('slowEventHook', {
type: 'slowEvent',
event: eventName,
time: eventHookTime,
location: location.href,
name: self.name,
domClass: e.target.className,
domName: e.target.tagName,
domId: e.target.id,
// domEvent: e
});
}
else {
self.trigger('eachEventHook', {
type: 'eachEvent',
event: eventName,
time: eventHookTime,
location: location.href,
name: self.name,
domClass: e.target.className,
domName: e.target.tagName,
domId: e.target.id,
// domEvent: e
});
}
window.addEventListener(eventName, eventCallback, false);
}, self.eventTimeout);
}
window.addEventListener(eventName, eventCallback, false);
})(events[i])
}
}
if (typeof evts === 'string') {
var events = [evts] || ['hashchange'];
}
else if (Object.prototype.toString.call(evts) === '[object Array]') {
var events = evts;
}
for (var i = 0; i < events.length; i++) {
(function(eventName) {
var eventCallback = function(e) {
var e = e || window.event;
var eventHookTime = 0;
var timeAfterEvent = function(time) {
eventHookTime = eventHookTime + time;
};
self.on('executing', timeAfterEvent);
window.removeEventListener(eventName, eventCallback);
setTimeout(function() {
self.trigger('eachEventHook', {
type: 'eachEvent',
event: eventName,
time: eventHookTime,
location: location.href,
name: self.name,
domClass: e.target.className,
domName: e.target.tagName,
domId: e.target.id,
// domEvent: e
});
window.addEventListener(eventName, eventCallback, false);
}, self.eventTimeout);
}
window.addEventListener(eventName, eventCallback, false);
})(events[i])
}
};
WebPerformance.prototype.addSlowEvents = function(evts) {
var self = this;
if (typeof evts === 'string') {
var events = [evts] || ['hashchange'];
}
else if (Object.prototype.toString.call(evts) === '[object Array]') {
var events = evts;
}
for (var i = 0; i < events.length; i++) {
(function(eventName) {
var eventCallback = function(e) {
var e = e || window.event;
var eventHookTime = 0;
var timeAfterEvent = function(time) {
eventHookTime = eventHookTime + time;
};
self.on('executing', timeAfterEvent);
window.removeEventListener(eventName, eventCallback);
setTimeout(function() {
if (eventHookTime > self.slowStandard) {
self.trigger('slowEventHook', {
type: 'slowEvent',
event: eventName,
time: eventHookTime,
location: location.href,
name: self.name,
domClass: e.target.className,
domName: e.target.tagName,
domId: e.target.id,
// domEvent: e
});
}
window.addEventListener(eventName, eventCallback, false);
}, self.eventTimeout);
}
window.addEventListener(eventName, eventCallback, false);
})(events[i])
}
};
WebPerformance.prototype.setOptions = function () {

@@ -151,4 +174,3 @@ this.onSlowFunc = this.options.onSlowFunc;

var self = this;
this.addEachEvents = this.addEvents('each');
this.addSlowEvents = this.addEvents('slow');
function timeout() {

@@ -155,0 +177,0 @@ if (requestAnimationFrame) {

{
"name": "jsperformance",
"version": "0.0.2",
"version": "0.0.3",
"description": "get web performance",

@@ -5,0 +5,0 @@ "main": "index.js",

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