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

trycatch

Package Overview
Dependencies
Maintainers
1
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

trycatch - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

80

lib/hook.js

@@ -43,23 +43,77 @@ /**

var onEvent = EventEmitter.prototype.on
EventEmitter.prototype.on = EventEmitter.prototype.addListener = function (type, callback) {
var newCallback
EventEmitter.prototype.on = EventEmitter.prototype.addListener = function (type, listener) {
var self = this
, list
, id
, newCallback
callback._wrappedCallback = callback._wrappedCallback || []
newCallback = wrap(callback, 'EventEmitter.on')
if (newCallback !== callback) {
callback._wrappedCallback.push(newCallback)
self._hookListeners = self._hookListeners || {}
id = listener._hookId = listener._hookId || ''+process.hrtime()
self._hookListeners[id] = self._hookListeners[id] || {}
if (!self._hookListeners[id][type]) {
self._hookListeners[id][type] = []
self._hookListeners[id][type].callback = function() {
var args = arguments
, list = self._hookListeners[id][type]
for (var i = 0, length = list.length; i < length; i++) {
list[i].apply(self, args)
}
}
}
arguments[1] = newCallback
return onEvent.apply(this, arguments)
newCallback = wrap(listener, 'EventEmitter.on')
if (newCallback !== listener) {
self._hookListeners[id][type].push(newCallback)
}
return onEvent.call(this, type, self._hookListeners[id][type].callback)
}
var removeEvent = EventEmitter.prototype.removeListener
EventEmitter.prototype.removeListener = function (type, callback) {
if (callback && Array.isArray(callback._wrappedCallback) && callback._wrappedCallback.length) {
arguments[1] = callback._wrappedCallback.pop()
EventEmitter.prototype.removeListener = function (type, listener) {
var empty = true
, id = listener._hookId
, list
, hookListener
, hookCallback
if (this._hookListeners &&
this._hookListeners[id] &&
this._hookListeners[id][type]) {
hookCallback = this._hookListeners[id][type].callback
hookListener = this._hookListeners[id]
list = hookListener[type]
list.shift()
if (!list.length) {
delete hookListener[type]
}
for (var i in hookListener) {
if (hookListener.hasOwnProperty(i)) {
empty = false
break;
}
}
if (empty) {
delete this._hookListeners[id]
}
listener = hookCallback
}
return removeEvent.apply(this, arguments)
return removeEvent.call(this, type, listener)
}
var removeAll = EventEmitter.prototype.removeAllListeners
EventEmitter.prototype.removeAllListeners = function (type) {
for (var id in this._hookListeners) {
if (this._hookListeners.hasOwnProperty(id)) {
if (this._hookListeners[id][type]) {
delete this._hookListeners[id][type]
}
}
}
return removeAll.call(this, type)
}
}
// If we delete an EventEmitter, we have a memory leak
var alreadyRequired
console.log('there')

2

package.json
{
"name": "trycatch",
"version": "0.1.2",
"version": "0.1.3",
"description": "An asynchronous exception handler with long stack traces for node.js",

@@ -5,0 +5,0 @@ "homepage": "http://github.com/CrabDude/trycatch",

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