Added boolean support to type matching

This commit is contained in:
Zaid Abdulla committed 2013-01-15 15:26:56 +03:00
1 parent 5c834568ab
commit 77d1c86b86
1 file changed
+4
+4
View File
@@ -1,5 +1,6 @@
UNDEFINED_TYPE = '[object Undefined]'
NULL_TYPE = '[object Null]'
BOOLEAN_TYPE = '[object Boolean]'
NUMBER_TYPE = '[object Number]'
STRING_TYPE = '[object String]'
ARRAY_TYPE = '[object Array]'
@@ -48,6 +49,9 @@ exports.matchType = (src, dst) ->
String(dst)
when NUMBER_TYPE
Number(dst)
when BOOLEAN_TYPE
v = String(dst).trim().toLowerCase()
v == 'true' or v == 'on' or v == '1'
else
dst