OSDN Git Service

7af102616abae9e950eda50f4c354879deb0def5
[pettanr/clientJs.git] / 0.6.x / js / core / 02_XType.js
1 /*\r
2  * http://pettanr.sourceforge.jp/test/type.html\r
3  * \r
4  * need xua\r
5  */\r
6 \r
7 X.Type = {\r
8         isObject : function(v) {\r
9                 return v !== null && typeof v === 'object';\r
10         },\r
11         \r
12         isFunction : function(v) {\r
13                 return typeof v === 'function';\r
14         },\r
15         isArray :\r
16                 X.UA.IE && X.UA.IE < 5 ? (function(v){ return v && typeof v.length === 'number';}) :\r
17                 window['Array'] ? (new Function('v', 'return v instanceof Array;')) :\r
18                 (function(v){ return Object.prototype.toString.call(v) === '[object Array]';}),\r
19         isBoolean : function(v) {\r
20                 return typeof v === 'boolean';\r
21         },\r
22         isString : function(v) {\r
23                 return typeof v === 'string';\r
24         },\r
25         isNumber : function(v) {\r
26                 return typeof v === 'number';\r
27         },\r
28         isFinite : function(v){\r
29                 return X.Type.isNumber(v) === true && isFinite(v);\r
30         },\r
31         isHTMLElement :\r
32                 // ie4\r
33                 X.UA.IE && X.UA.IE < 5 ? (function(v){ return v && v.tagName && v.all;}) :\r
34                 window['HTMLElement'] ? (new Function('v', 'return v instanceof HTMLElement')) :\r
35                 (function(v){ return v && v.nodeType === 1 && v.appendChild;}),\r
36         /*\r
37         isElementCollection : function(v) {\r
38                 return (Object.prototype.toString.call(v) === "[object HTMLCollection]");\r
39         },\r
40         */\r
41         isNull : function(v) {\r
42                 return v === null;\r
43         },\r
44         isUndefined : function(v) {\r
45                 return typeof v === 'undefined';\r
46         }\r
47 };\r