fix types.

This commit is contained in:
Christopher Jeffrey 2013-02-24 08:02:07 -06:00
parent 6c6b4f8f66
commit 60edb202a3
1 changed files with 23 additions and 3 deletions

View File

@ -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: