Skip to content

Commit 2c266b9

Browse files
committed
merged pull requests 6 and 8 and bumped version
1 parent e1ca2ac commit 2c266b9

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

index.js

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,21 @@ var _on = EventEmitter.prototype.on
129129
, _removeListener = EventEmitter.prototype.removeListener;
130130

131131
EventEmitter.prototype.addListener = function(event, callback) {
132-
return _addListener.call(this, event, wrap_callback(callback, 'EventEmitter.addListener'));
132+
var args = Array.prototype.slice.call(arguments);
133+
args[1] = wrap_callback(callback, 'EventEmitter.addListener');
134+
return _addListener.apply(this, args);
133135
};
134136

135137
EventEmitter.prototype.on = function(event, callback) {
136-
return _on.call(this, event, wrap_callback(callback, 'EventEmitter.on'));
138+
var args = Array.prototype.slice.call(arguments);
139+
args[1] = wrap_callback(callback, 'EventEmitter.on');
140+
return _on.apply(this, args);
137141
};
138142

139143
EventEmitter.prototype.once = function(event, callback) {
140-
return _once.call(this, event, wrap_callback(callback, 'EventEmitter.once'));
144+
var args = Array.prototype.slice.call(arguments);
145+
args[1] = wrap_callback(callback, 'EventEmitter.once');
146+
return _once.apply(this, args);
141147
};
142148

143149
EventEmitter.prototype.removeListener = function(event, callback) {
@@ -173,18 +179,24 @@ EventEmitter.prototype.removeListener = function(event, callback) {
173179
var _nextTick = process.nextTick;
174180

175181
process.nextTick = function(callback) {
176-
return _nextTick.call(this, wrap_callback(callback, 'process.nextTick'));
182+
var args = Array.prototype.slice.call(arguments);
183+
args[0] = wrap_callback(callback, 'process.nextTick');
184+
return _nextTick.apply(this, args);
177185
};
178186

179187

180188

181189
var _setTimeout = global.setTimeout
182190
, _setInterval = global.setInterval;
183191

184-
global.setTimeout = function(callback, interval) {
185-
return _setTimeout.call(this, wrap_callback(callback, 'process.nextTick'), interval);
192+
global.setTimeout = function(callback) {
193+
var args = Array.prototype.slice.call(arguments);
194+
args[0] = wrap_callback(callback, 'process.nextTick');
195+
return _setTimeout.apply(this, args);
186196
};
187197

188-
global.setInterval = function(callback, interval) {
189-
return _setInterval.call(this, wrap_callback(callback, 'process.nextTick'), interval);
198+
global.setInterval = function(callback) {
199+
var args = Array.prototype.slice.call(arguments);
200+
args[0] = wrap_callback(callback, 'process.nextTick');
201+
return _setInterval.apply(this, args);
190202
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"author": "Matt Insler <[email protected]> (www.mattinsler.com)",
33
"name": "longjohn",
44
"description": "Long stack traces for node.js inspired by https://github.com/tlrobinson/long-stack-traces",
5-
"version": "0.0.4",
5+
"version": "0.0.5",
66
"repository": {
77
"type": "git",
88
"url": "[email protected]:mattinsler/longjohn.git"

test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,8 @@ emitter.removeListener('foo', foo);
7676
console.log('Print once');
7777
emitter.emit('foo');
7878
// should print foo 1 time
79+
80+
should show { '0': 1, '1': 2, '2': 3 }
81+
setTimeout(function () {console.log(arguments);}, 1000, 1, 2, 3);
82+
//should show { '0': 1, '1': 2, '2': 3 }
83+
setInterval(function () {console.log(arguments);}, 1000, 1, 2, 3);

0 commit comments

Comments
 (0)