From 77469928ab2c6c8b361edb6b420c63d359b00ebf Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 11 Oct 2013 09:58:50 +0000 Subject: [PATCH] feature(util) retExec: add any count of params --- lib/util.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/util.js b/lib/util.js index b0462483..4fcc299b 100644 --- a/lib/util.js +++ b/lib/util.js @@ -697,11 +697,22 @@ Util = exports || {}; * @param pCallBack * @param pArg */ - Util.retExec = function(pCallBack, pArg) { - return function(pArgument) { - if ( !Util.isUndefined(pArg) ) - pArgument = pArg; - Util.exec(pCallBack, pArgument); + Util.retExec = function() { + var args = arguments; + + return function() { + var argsLocal, callback, + n = arguments.length; + + if (!n) + argsLocal = args; + else { + callback = args[0]; + argsLocal = arguments; + [].unshift.call(argsLocal, callback); + } + + Util.exec.apply(null, argsLocal); }; };