From 60edb202a32af5545c0e19cffe37feeed8371884 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sun, 24 Feb 2013 08:02:07 -0600 Subject: [PATCH] fix types. --- lib/tput.js | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/lib/tput.js b/lib/tput.js index 27e5bf5..ed344f4 100644 --- a/lib/tput.js +++ b/lib/tput.js @@ -311,11 +311,27 @@ Tput.prototype.compile = function(key) { if (alias) self.methods[alias] = self.methods[key]; }); - Tput.bools.concat(Tput.numbers).concat(Tput.strings).forEach(function(key) { + Tput.bools.forEach(function(key) { + if (self.methods[key] == null) self.methods[key] = false; + }); + + Tput.numbers.forEach(function(key) { + if (self.methods[key] == null) self.methods[key] = -1; + }); + + Tput.strings.forEach(function(key) { if (!self.methods[key]) self.methods[key] = noop; }); + // Tput.bools.concat(Tput.numbers).concat(Tput.strings).forEach(function(key) { + // if (!self.methods[key]) self.methods[key] = noop; + // }); + Object.keys(self.methods).forEach(function(key) { + if (typeof self.methods[key] !== 'function') { + self[key] = self.methods[key]; + return; + } self[key] = function() { var args = Array.prototype.slice.call(arguments); return self.methods[key].call(self, args); @@ -329,10 +345,14 @@ Tput.prototype._compile = function(val) { switch (typeof val) { case 'boolean': return val; - // return val ? 'true' : 'false'; + // return function() { + // return val ? 'true' : 'false'; + // }; case 'number': return val; - // return val === -1 ? null : val; + // return function() { + // return val === -1 ? null : val; + // }; case 'string': break; default: