From 87bd317f64bfcc08548e16d8f36b54b2073dd383 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 12 Feb 2014 04:59:34 -0500 Subject: [PATCH] refactor(util) retExec, add bind --- lib/util.js | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/lib/util.js b/lib/util.js index 425e8a3a..b73c2ced 100644 --- a/lib/util.js +++ b/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; }; /**