From fd30eb21526bdaa5aabb15523b0a766e0cbbe535 Mon Sep 17 00:00:00 2001 From: Yosuke Furukawa Date: Fri, 16 Jan 2015 02:55:29 +0900 Subject: [PATCH] src: fix jslint errors PR-URL: https://github.com/iojs/io.js/pull/449 Reviewed-By: Ben Noordhuis --- lib/_debugger.js | 10 +-- lib/_http_client.js | 2 +- lib/events.js | 148 ++++++++++++++++++++++---------------------- lib/repl.js | 2 +- lib/timers.js | 2 +- lib/util.js | 4 +- src/node.js | 14 ++--- 7 files changed, 91 insertions(+), 91 deletions(-) diff --git a/lib/_debugger.js b/lib/_debugger.js index 99b55a8b50e07d..a0579e5cf5d18f 100644 --- a/lib/_debugger.js +++ b/lib/_debugger.js @@ -1269,11 +1269,11 @@ Interface.prototype.unwatch = function(expr) { // List watchers Interface.prototype.watchers = function() { - var self = this, - verbose = arguments[0] || false, - callback = arguments[1] || function() {}, - waiting = this._watchers.length, - values = []; + var self = this; + var verbose = arguments[0] || false; + var callback = arguments[1] || function() {}; + var waiting = this._watchers.length; + var values = []; this.pause(); diff --git a/lib/_http_client.js b/lib/_http_client.js index 0b4d2947559649..b9dd6bd52c63a9 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -500,7 +500,7 @@ ClientRequest.prototype._deferToConnect = function(method, arguments_, cb) { if (cb) { cb(); } }); } - } + }; if (!self.socket) { self.once('socket', onSocket); } else { diff --git a/lib/events.js b/lib/events.js index 8c7748e0d7bcab..2f3215a4112ca7 100644 --- a/lib/events.js +++ b/lib/events.js @@ -191,90 +191,90 @@ EventEmitter.prototype.once = function once(type, listener) { // emits a 'removeListener' event iff the listener was removed EventEmitter.prototype.removeListener = function removeListener(type, listener) { - var list, position, length, i; - - if (!util.isFunction(listener)) - throw TypeError('listener must be a function'); - - if (!this._events || !this._events[type]) - return this; - - list = this._events[type]; - length = list.length; - position = -1; - - if (list === listener || - (util.isFunction(list.listener) && list.listener === listener)) { - delete this._events[type]; - if (this._events.removeListener) - this.emit('removeListener', type, listener); - - } else if (util.isObject(list)) { - for (i = length; i-- > 0;) { - if (list[i] === listener || - (list[i].listener && list[i].listener === listener)) { - position = i; - break; + var list, position, length, i; + + if (!util.isFunction(listener)) + throw TypeError('listener must be a function'); + + if (!this._events || !this._events[type]) + return this; + + list = this._events[type]; + length = list.length; + position = -1; + + if (list === listener || + (util.isFunction(list.listener) && list.listener === listener)) { + delete this._events[type]; + if (this._events.removeListener) + this.emit('removeListener', type, listener); + + } else if (util.isObject(list)) { + for (i = length; i-- > 0;) { + if (list[i] === listener || + (list[i].listener && list[i].listener === listener)) { + position = i; + 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; - - 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 = function removeAllListeners(type) { - var key, listeners; - - if (!this._events) - return this; - - // not listening for removeListener, no need to emit - if (!this._events.removeListener) { - if (arguments.length === 0) - this._events = {}; - else if (this._events[type]) - delete this._events[type]; - return this; - } + var key, listeners; + + if (!this._events) + return this; + + // not listening for removeListener, no need to emit + if (!this._events.removeListener) { + if (arguments.length === 0) + this._events = {}; + 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; - } + // 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]; + 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]; + 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; -}; + return this; + }; EventEmitter.prototype.listeners = function listeners(type) { var ret; diff --git a/lib/repl.js b/lib/repl.js index b9ce053c915d7f..2d7dc14604078e 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -398,7 +398,7 @@ function ArrayStream() { data.forEach(function(line) { self.emit('data', line + '\n'); }); - } + }; } util.inherits(ArrayStream, Stream); ArrayStream.prototype.readable = true; diff --git a/lib/timers.js b/lib/timers.js index b809fd132ce9c7..99921488003326 100644 --- a/lib/timers.js +++ b/lib/timers.js @@ -193,7 +193,7 @@ exports.setTimeout = function(callback, after) { var args = Array.prototype.slice.call(arguments, 2); timer._onTimeout = function() { callback.apply(timer, args); - } + }; } if (process.domain) timer.domain = process.domain; diff --git a/lib/util.js b/lib/util.js index 891a376c2d955c..b2bfa7c5ddd56b 100644 --- a/lib/util.js +++ b/lib/util.js @@ -355,8 +355,8 @@ function formatPrimitive(ctx, value) { return ctx.stylize('undefined', 'undefined'); if (isString(value)) { var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') - .replace(/'/g, "\\'") - .replace(/\\"/g, '"') + '\''; + .replace(/'/g, "\\'") + .replace(/\\"/g, '"') + '\''; return ctx.stylize(simple, 'string'); } if (isNumber(value)) { diff --git a/src/node.js b/src/node.js index e6056797b2a344..3179378fbc5ae6 100644 --- a/src/node.js +++ b/src/node.js @@ -252,10 +252,10 @@ // strip the gyp comment line at the beginning config = config.split('\n') - .slice(1) - .join('\n') - .replace(/"/g, '\\"') - .replace(/'/g, '"'); + .slice(1) + .join('\n') + .replace(/"/g, '\\"') + .replace(/'/g, '"'); process.config = JSON.parse(config, function(key, value) { if (value === 'true') return true; @@ -773,15 +773,15 @@ NativeModule.getCached = function(id) { return NativeModule._cache[id]; - } + }; NativeModule.exists = function(id) { return NativeModule._source.hasOwnProperty(id); - } + }; NativeModule.getSource = function(id) { return NativeModule._source[id]; - } + }; NativeModule.wrap = function(script) { return NativeModule.wrapper[0] + script + NativeModule.wrapper[1];