From e20c5de5fc9e6d1eecc30d739c2c307ecb6744a1 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 3 Feb 2014 04:16:01 -0500 Subject: [PATCH] feature(util) rm retFunc --- lib/client/socket.js | 2 +- lib/server/commander.js | 2 +- lib/server/console.js | 4 ++-- lib/server/dir.js | 2 +- lib/util.js | 14 +------------- 5 files changed, 6 insertions(+), 18 deletions(-) diff --git a/lib/client/socket.js b/lib/client/socket.js index 9e57fceb..4becda7b 100644 --- a/lib/client/socket.js +++ b/lib/client/socket.js @@ -27,7 +27,7 @@ var CloudCmd, Util, DOM, CloudFunc, io; function init(callback) { DOM.jsload('/socket.io/lib/socket.io.js', { - onerror : Util.retFunc(Util.log, ERROR_MSG), + onerror : Util.log.bind(Util, ERROR_MSG), onload : function() { Util.exec(callback); diff --git a/lib/server/commander.js b/lib/server/commander.js index 2d386d0f..d5b3d2bb 100644 --- a/lib/server/commander.js +++ b/lib/server/commander.js @@ -58,7 +58,7 @@ path : p.path }, - fill = Util.retFunc(fillJSON, filesData); + fill = fillJSON.bind(null, filesData); if (n) for (i = 0; i < n; i++) { diff --git a/lib/server/console.js b/lib/server/console.js index 27181388..ae1f7a80 100644 --- a/lib/server/console.js +++ b/lib/server/console.js @@ -79,7 +79,7 @@ Clients[ConNum] = true; onMessage = getOnMessage(ConNum, callback); - onDisconnect = Util.retFunc(function(conNum) { + onDisconnect = function(conNum) { Clients[conNum] = ClientFuncs[conNum] = null; @@ -87,7 +87,7 @@ socket.removeListener('message', onMessage, clientSocket); socket.removeListener('disconnect', onDisconnect, clientSocket); - }, ConNum); + }.bind(null, ConNum); socket.on('message', onMessage, clientSocket); socket.on('disconnect', onDisconnect, clientSocket); diff --git a/lib/server/dir.js b/lib/server/dir.js index 46db3d8b..47c371c9 100644 --- a/lib/server/dir.js +++ b/lib/server/dir.js @@ -79,7 +79,7 @@ for (var i = 0; i < n; i++) { lDirPath = path.join(lPath, pFiles[i]); - process.nextTick(Util.retFunc(getDirInfo, lDirPath)); + process.nextTick(getDirInfo.bind(null, lDirPath)); } } diff --git a/lib/util.js b/lib/util.js index 6dfc326e..6173b882 100644 --- a/lib/util.js +++ b/lib/util.js @@ -441,7 +441,7 @@ * @param pArg */ this.log = function() { - var args = Util.slice(arguments), + var args = this.slice(arguments), console = Scope.console, lDate = '[' + Util.getDate() + '] '; @@ -760,18 +760,6 @@ Util.exec.apply(null, argsLocal); }; }; - - /** - * return function wich exec function in params - * @param arguments: callback, args - */ - this.retFunc = function() { - var args = arguments; - - return function() { - return Util.exec.apply(null, args); - }; - }; /** * function return false