mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-21 10:38:26 +00:00
feature(util) execIfExist -> exec.ifExist
This commit is contained in:
parent
8060ba2b1b
commit
099d1bfa82
1 changed files with 19 additions and 19 deletions
38
lib/util.js
38
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;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue