mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
refactor(util) retExec, add bind
This commit is contained in:
parent
97567e984e
commit
87bd317f64
1 changed files with 17 additions and 10 deletions
27
lib/util.js
27
lib/util.js
|
|
@ -55,6 +55,17 @@
|
|||
}
|
||||
},
|
||||
|
||||
this.bind = function(callback) {
|
||||
var result,
|
||||
args = Util.slice(arguments, 1),
|
||||
bind = Function.prototype.bind;
|
||||
|
||||
args.unshift(null);
|
||||
result = bind.apply(callback, args);
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* ad new line (if it's not)
|
||||
* @param {string} pText
|
||||
|
|
@ -710,17 +721,13 @@
|
|||
* return save exec function
|
||||
* @param callback
|
||||
*/
|
||||
this.retExec = function(callback) {
|
||||
var args = Util.slice(arguments);
|
||||
this.retExec = function() {
|
||||
var result,
|
||||
exec = Util.exec.bind(Util);
|
||||
|
||||
return function() {
|
||||
var argsLocal = Util.slice(arguments);
|
||||
callback;
|
||||
|
||||
argsLocal = args.concat(argsLocal);
|
||||
|
||||
Util.exec.apply(null, argsLocal);
|
||||
};
|
||||
result = Util.bind.apply(exec, arguments);
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue