src: fix jslint errors
PR-URL: https://github.com/iojs/io.js/pull/449 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit is contained in:
parent
946eabd18f
commit
fd30eb2152
@ -1269,11 +1269,11 @@ Interface.prototype.unwatch = function(expr) {
|
|||||||
|
|
||||||
// List watchers
|
// List watchers
|
||||||
Interface.prototype.watchers = function() {
|
Interface.prototype.watchers = function() {
|
||||||
var self = this,
|
var self = this;
|
||||||
verbose = arguments[0] || false,
|
var verbose = arguments[0] || false;
|
||||||
callback = arguments[1] || function() {},
|
var callback = arguments[1] || function() {};
|
||||||
waiting = this._watchers.length,
|
var waiting = this._watchers.length;
|
||||||
values = [];
|
var values = [];
|
||||||
|
|
||||||
this.pause();
|
this.pause();
|
||||||
|
|
||||||
|
@ -500,7 +500,7 @@ ClientRequest.prototype._deferToConnect = function(method, arguments_, cb) {
|
|||||||
if (cb) { cb(); }
|
if (cb) { cb(); }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
if (!self.socket) {
|
if (!self.socket) {
|
||||||
self.once('socket', onSocket);
|
self.once('socket', onSocket);
|
||||||
} else {
|
} else {
|
||||||
|
138
lib/events.js
138
lib/events.js
@ -191,90 +191,90 @@ EventEmitter.prototype.once = function once(type, listener) {
|
|||||||
// emits a 'removeListener' event iff the listener was removed
|
// emits a 'removeListener' event iff the listener was removed
|
||||||
EventEmitter.prototype.removeListener =
|
EventEmitter.prototype.removeListener =
|
||||||
function removeListener(type, listener) {
|
function removeListener(type, listener) {
|
||||||
var list, position, length, i;
|
var list, position, length, i;
|
||||||
|
|
||||||
if (!util.isFunction(listener))
|
if (!util.isFunction(listener))
|
||||||
throw TypeError('listener must be a function');
|
throw TypeError('listener must be a function');
|
||||||
|
|
||||||
if (!this._events || !this._events[type])
|
if (!this._events || !this._events[type])
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
list = this._events[type];
|
list = this._events[type];
|
||||||
length = list.length;
|
length = list.length;
|
||||||
position = -1;
|
position = -1;
|
||||||
|
|
||||||
if (list === listener ||
|
if (list === listener ||
|
||||||
(util.isFunction(list.listener) && list.listener === listener)) {
|
(util.isFunction(list.listener) && list.listener === listener)) {
|
||||||
delete this._events[type];
|
delete this._events[type];
|
||||||
if (this._events.removeListener)
|
if (this._events.removeListener)
|
||||||
this.emit('removeListener', type, listener);
|
this.emit('removeListener', type, listener);
|
||||||
|
|
||||||
} else if (util.isObject(list)) {
|
} else if (util.isObject(list)) {
|
||||||
for (i = length; i-- > 0;) {
|
for (i = length; i-- > 0;) {
|
||||||
if (list[i] === listener ||
|
if (list[i] === listener ||
|
||||||
(list[i].listener && list[i].listener === listener)) {
|
(list[i].listener && list[i].listener === listener)) {
|
||||||
position = i;
|
position = i;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (position < 0)
|
||||||
|
return this;
|
||||||
|
|
||||||
|
if (list.length === 1) {
|
||||||
|
list.length = 0;
|
||||||
|
delete this._events[type];
|
||||||
|
} else {
|
||||||
|
spliceOne(list, position);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this._events.removeListener)
|
||||||
|
this.emit('removeListener', type, listener);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (position < 0)
|
|
||||||
return this;
|
return this;
|
||||||
|
};
|
||||||
if (list.length === 1) {
|
|
||||||
list.length = 0;
|
|
||||||
delete this._events[type];
|
|
||||||
} else {
|
|
||||||
spliceOne(list, position);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this._events.removeListener)
|
|
||||||
this.emit('removeListener', type, listener);
|
|
||||||
}
|
|
||||||
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
EventEmitter.prototype.removeAllListeners =
|
EventEmitter.prototype.removeAllListeners =
|
||||||
function removeAllListeners(type) {
|
function removeAllListeners(type) {
|
||||||
var key, listeners;
|
var key, listeners;
|
||||||
|
|
||||||
if (!this._events)
|
if (!this._events)
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
// not listening for removeListener, no need to emit
|
// not listening for removeListener, no need to emit
|
||||||
if (!this._events.removeListener) {
|
if (!this._events.removeListener) {
|
||||||
if (arguments.length === 0)
|
if (arguments.length === 0)
|
||||||
this._events = {};
|
this._events = {};
|
||||||
else if (this._events[type])
|
else if (this._events[type])
|
||||||
|
delete this._events[type];
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// emit removeListener for all listeners on all events
|
||||||
|
if (arguments.length === 0) {
|
||||||
|
for (key in this._events) {
|
||||||
|
if (key === 'removeListener') continue;
|
||||||
|
this.removeAllListeners(key);
|
||||||
|
}
|
||||||
|
this.removeAllListeners('removeListener');
|
||||||
|
this._events = {};
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
listeners = this._events[type];
|
||||||
|
|
||||||
|
if (util.isFunction(listeners)) {
|
||||||
|
this.removeListener(type, listeners);
|
||||||
|
} else if (Array.isArray(listeners)) {
|
||||||
|
// LIFO order
|
||||||
|
while (listeners.length)
|
||||||
|
this.removeListener(type, listeners[listeners.length - 1]);
|
||||||
|
}
|
||||||
delete this._events[type];
|
delete this._events[type];
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// emit removeListener for all listeners on all events
|
return this;
|
||||||
if (arguments.length === 0) {
|
};
|
||||||
for (key in this._events) {
|
|
||||||
if (key === 'removeListener') continue;
|
|
||||||
this.removeAllListeners(key);
|
|
||||||
}
|
|
||||||
this.removeAllListeners('removeListener');
|
|
||||||
this._events = {};
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
listeners = this._events[type];
|
|
||||||
|
|
||||||
if (util.isFunction(listeners)) {
|
|
||||||
this.removeListener(type, listeners);
|
|
||||||
} else if (Array.isArray(listeners)) {
|
|
||||||
// LIFO order
|
|
||||||
while (listeners.length)
|
|
||||||
this.removeListener(type, listeners[listeners.length - 1]);
|
|
||||||
}
|
|
||||||
delete this._events[type];
|
|
||||||
|
|
||||||
return this;
|
|
||||||
};
|
|
||||||
|
|
||||||
EventEmitter.prototype.listeners = function listeners(type) {
|
EventEmitter.prototype.listeners = function listeners(type) {
|
||||||
var ret;
|
var ret;
|
||||||
|
@ -398,7 +398,7 @@ function ArrayStream() {
|
|||||||
data.forEach(function(line) {
|
data.forEach(function(line) {
|
||||||
self.emit('data', line + '\n');
|
self.emit('data', line + '\n');
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
util.inherits(ArrayStream, Stream);
|
util.inherits(ArrayStream, Stream);
|
||||||
ArrayStream.prototype.readable = true;
|
ArrayStream.prototype.readable = true;
|
||||||
|
@ -193,7 +193,7 @@ exports.setTimeout = function(callback, after) {
|
|||||||
var args = Array.prototype.slice.call(arguments, 2);
|
var args = Array.prototype.slice.call(arguments, 2);
|
||||||
timer._onTimeout = function() {
|
timer._onTimeout = function() {
|
||||||
callback.apply(timer, args);
|
callback.apply(timer, args);
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process.domain) timer.domain = process.domain;
|
if (process.domain) timer.domain = process.domain;
|
||||||
|
@ -355,8 +355,8 @@ function formatPrimitive(ctx, value) {
|
|||||||
return ctx.stylize('undefined', 'undefined');
|
return ctx.stylize('undefined', 'undefined');
|
||||||
if (isString(value)) {
|
if (isString(value)) {
|
||||||
var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
|
var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
|
||||||
.replace(/'/g, "\\'")
|
.replace(/'/g, "\\'")
|
||||||
.replace(/\\"/g, '"') + '\'';
|
.replace(/\\"/g, '"') + '\'';
|
||||||
return ctx.stylize(simple, 'string');
|
return ctx.stylize(simple, 'string');
|
||||||
}
|
}
|
||||||
if (isNumber(value)) {
|
if (isNumber(value)) {
|
||||||
|
14
src/node.js
14
src/node.js
@ -252,10 +252,10 @@
|
|||||||
|
|
||||||
// strip the gyp comment line at the beginning
|
// strip the gyp comment line at the beginning
|
||||||
config = config.split('\n')
|
config = config.split('\n')
|
||||||
.slice(1)
|
.slice(1)
|
||||||
.join('\n')
|
.join('\n')
|
||||||
.replace(/"/g, '\\"')
|
.replace(/"/g, '\\"')
|
||||||
.replace(/'/g, '"');
|
.replace(/'/g, '"');
|
||||||
|
|
||||||
process.config = JSON.parse(config, function(key, value) {
|
process.config = JSON.parse(config, function(key, value) {
|
||||||
if (value === 'true') return true;
|
if (value === 'true') return true;
|
||||||
@ -773,15 +773,15 @@
|
|||||||
|
|
||||||
NativeModule.getCached = function(id) {
|
NativeModule.getCached = function(id) {
|
||||||
return NativeModule._cache[id];
|
return NativeModule._cache[id];
|
||||||
}
|
};
|
||||||
|
|
||||||
NativeModule.exists = function(id) {
|
NativeModule.exists = function(id) {
|
||||||
return NativeModule._source.hasOwnProperty(id);
|
return NativeModule._source.hasOwnProperty(id);
|
||||||
}
|
};
|
||||||
|
|
||||||
NativeModule.getSource = function(id) {
|
NativeModule.getSource = function(id) {
|
||||||
return NativeModule._source[id];
|
return NativeModule._source[id];
|
||||||
}
|
};
|
||||||
|
|
||||||
NativeModule.wrap = function(script) {
|
NativeModule.wrap = function(script) {
|
||||||
return NativeModule.wrapper[0] + script + NativeModule.wrapper[1];
|
return NativeModule.wrapper[0] + script + NativeModule.wrapper[1];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user