From 2b5e991ef3138b7a5f37764641ef1807a133521e Mon Sep 17 00:00:00 2001 From: Andrew Stewart Date: Thu, 5 Jun 2014 16:30:05 -0700 Subject: [PATCH] Clean up some of the utility functions --- lib/utils.js | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/lib/utils.js b/lib/utils.js index 28d07c0..7accf77 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -84,7 +84,9 @@ var Utils = module.exports = { // // Returns subclass subclass: function subclass(child, parent) { - var ctor = function() { this.constructor = child; }; + var ctor = function() { + this.constructor = child; + }; for (var key in parent) { if (Object.hasOwnProperty.call(parent, key)) { @@ -109,8 +111,13 @@ var Utils = module.exports = { // // Returns base proxyFunctionsToObject: function proxyFunctionsToObject(methods, target, base, force) { - if (base == null) { base = this; } - if (force == null) { force = false; } + if (base == null) { + base = this; + } + + if (force == null) { + force = false; + } var fn = function(method) { return base[method] = function() { @@ -121,8 +128,9 @@ var Utils = module.exports = { for (var i = 0; i < methods.length; i++) { var method = methods[i]; - if (!force) { - if (typeof base[method] === 'function') { continue; } + + if (!force && typeof(base[method]) === 'function') { + continue; } fn(method); @@ -138,10 +146,15 @@ var Utils = module.exports = { // // Returns base proxyTestStubs: function proxyTestStubs(methods, base) { - if (base == null) { base = this; } + if (base == null) { + base = this; + } methods.forEach(function(method) { - base[method] = function() { return true; }; + base[method] = function() { + return true; + }; + base.commandList.push(method); }); @@ -165,7 +178,9 @@ var Utils = module.exports = { // // Returns a function wrapper bind: function bind(fn, me) { - return function() { return fn.apply(me, arguments); }; + return function() { + return fn.apply(me, arguments); + }; }, // Public: Adds necessary utils to global namespace, along with base class