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.0 to 0.1.1

4

lib/formatStackTrace.js

@@ -65,3 +65,5 @@ // Copyright 2006-2008 the V8 project authors. All rights reserved.

line = colors.red(line);
}
} else {
line = colors.white(line);
}
}

@@ -68,0 +70,0 @@

@@ -44,7 +44,10 @@ /**

EventEmitter.prototype.on = EventEmitter.prototype.addListener = function (type, callback) {
var newCallback = wrap(callback, 'EventEmitter.on')
var newCallback
callback._wrappedCallback = callback._wrappedCallback || []
newCallback = wrap(callback, 'EventEmitter.on')
if (newCallback !== callback) {
callback.wrappedCallback = newCallback
arguments[1] = newCallback
callback._wrappedCallback.push(newCallback)
}
arguments[1] = newCallback
return onEvent.apply(this, arguments)

@@ -54,4 +57,4 @@ }

EventEmitter.prototype.removeListener = function (type, callback) {
if (callback && callback.hasOwnProperty("wrappedCallback")) {
arguments[1] = callback.wrappedCallback
if (callback && Array.isArray(callback._wrappedCallback)) {
arguments[1] = callback._wrappedCallback.pop()
}

@@ -58,0 +61,0 @@ return removeEvent.apply(this, arguments)

{
"name": "trycatch",
"version": "0.1.0",
"version": "0.1.1",
"description": "An asynchronous exception handler with long stack traces for node.js",

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

@@ -1,5 +0,5 @@

var assert = require('assert'),
util = require("util"),
events = require("events"),
trycatch = require('../lib/trycatch')
var trycatch = require('../lib/trycatch')
, assert = require('assert')
, util = require("util")
, events = require("events")

@@ -15,7 +15,4 @@ /*

describe('EventEmitter', function() {
function EE() {
this.on('sync', this.onSync)
this.on('async', this.onAsync)
}
util.inherits(EE, events.EventEmitter);
function EE() {}
util.inherits(EE, events.EventEmitter)
EE.prototype.sync = function() {

@@ -40,16 +37,22 @@ this.emit('sync')

trycatch(function() {
(new EE).sync()
}, function(err) {
assert.equal(err.message, 'Sync')
done()
})
var ee = new EE
ee.on('sync', ee.onSync)
ee.sync()
}
, function(err) {
assert.equal(err.message, 'Sync')
done()
})
})
it('should catch as when emit called asynchronously', function(done) {
it('should catch when emit called asynchronously', function(done) {
trycatch(function() {
(new EE).async()
}, function(err) {
assert.equal(err.message, 'Async')
done()
})
var ee = new EE
ee.on('async', ee.onAsync)
ee.async()
}
, function(err) {
assert.equal(err.message, 'Async')
done()
})
})

@@ -59,10 +62,30 @@

trycatch(function() {
setTimeout(function() {
(new EE).async()
}, 0);
}, function(err) {
assert.equal(err.message, 'Async')
done()
})
setTimeout(function() {
var ee = new EE
ee.on('async', ee.onAsync)
ee.async()
}, 0)
}
, function(err) {
assert.equal(err.message, 'Async')
done()
})
})
it('should removeListener if addListener called multiple times', function(done) {
var ee = new EE
function foo() {
throw new Error('Event handler should have been removed')
}
ee.on('foo', foo)
ee.on('foo', foo)
ee.removeListener('foo', foo)
ee.removeListener('foo', foo)
assert.doesNotThrow(function() {
ee.emit('foo')
})
done()
})
})
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