diff --git a/lib/util.js b/lib/util.js index 60eb1803..d736e53d 100644 --- a/lib/util.js +++ b/lib/util.js @@ -612,7 +612,7 @@ var FILE = '[object File]', name, is; - name = Util.execIfExist(variable, 'toString'); + name = Util.exec.ifExist(variable, 'toString'); is = name === FILE; @@ -806,6 +806,22 @@ return ret; }; + /** + * exec function if it exist in object + * @pArg + */ + exec.ifExist = function(obj, name, arg) { + var ret, + func = obj && obj[name]; + + if (func) { + func = func.bind(obj); + ret = Util.exec(func, arg); + } + + return ret; + }; + exec.parallel = function(funcs, callback) { var i, func, funcsCount = funcs.length, @@ -845,22 +861,6 @@ return exec; } - /** - * exec function if it exist in object - * @pArg - */ - this.execIfExist = function(pObj, pName, pArg) { - var ret, - func = pObj && pObj[pName]; - - if (func) { - func = func.bind(pObj); - ret = Util.exec(func, pArg); - } - - return ret; - }; - /** * function do conditional save exec of function * @param pCondition @@ -968,7 +968,7 @@ this.time = function(name) { var console = Scope.console; - Util.execIfExist(console, 'time', name); + Util.exec.ifExist(console, 'time', name); return this; }; @@ -980,7 +980,7 @@ this.timeEnd = function(name) { var console = Scope.console; - Util.execIfExist(console, 'timeEnd', name); + Util.exec.ifExist(console, 'timeEnd', name); return this; };