Comparing version 0.1.0 to 0.1.1
@@ -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() | ||
}) | ||
}) |
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
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
42602
567
0
1