11/**
22 * runtime.js
3- * Version 0.5.0
3+ * Version 0.5.1
44 * September 14th, 2016
55 *
66 * Copyright (c) 2016 Baptiste Augrain
@@ -551,6 +551,7 @@ var Type = {
551551 for ( var name in item ) {
552552 return false ;
553553 }
554+
554555 return true ;
555556 } , // }}}
556557 isEnumerable : function ( item ) { // {{{
@@ -572,16 +573,20 @@ var Type = {
572573 var type = typeof item ;
573574 return type === 'string' || type === 'number' || type === 'boolean' ;
574575 } , // }}}
575- isRegExp : function ( item ) { // {{{
576- return item !== null && typeof item === 'object' && Object . prototype . toString . call ( item ) === '[object RegExp]' ;
577- } , // }}}
578576 isString : function ( item ) { // {{{
579577 return typeof item === 'string' ;
580578 } , // }}}
581579 isValue : function ( item ) { // {{{
582580 return item != null && typeof item !== 'undefined' ;
583- } , // }}}
584- typeOf : function ( item ) { // {{{
581+ } // }}}
582+ } ;
583+
584+ if ( / f o o / . constructor . name === 'RegExp' ) {
585+ Type . isRegExp = function ( item ) { // {{{
586+ return item !== null && typeof item === 'object' && item . constructor . name === 'RegExp' ;
587+ } ; // }}}
588+
589+ Type . typeOf = function ( item ) { // {{{
585590 var type = typeof item ;
586591
587592 if ( type === 'object' ) {
@@ -622,8 +627,58 @@ var Type = {
622627 else {
623628 return type ;
624629 }
625- } // }}}
626- } ;
630+ } ; // }}}
631+ }
632+ else {
633+ Type . isRegExp = function ( item ) { // {{{
634+ return item !== null && typeof item === 'object' && Object . prototype . toString . call ( item ) === '[object RegExp]' ;
635+ } ; // }}}
636+
637+ Type . typeOf = function ( item ) { // {{{
638+ var type = typeof item ;
639+
640+ if ( type === 'object' ) {
641+ var name = Object . prototype . toString . call ( item ) ;
642+
643+ if ( item === null ) {
644+ return 'null' ;
645+ }
646+ else if ( name === '[object Date]' ) {
647+ return 'date' ;
648+ }
649+ else if ( name === '[object RegExp]' ) {
650+ return 'regex' ;
651+ }
652+ else if ( item . nodeName ) {
653+ if ( item . nodeType === 1 ) {
654+ return 'element' ;
655+ }
656+ if ( item . nodeType === 3 ) {
657+ return ( / \S / ) . test ( item . nodeValue ) ? 'textnode' : 'whitespace' ;
658+ }
659+ }
660+ else if ( typeof item . length === 'number' ) {
661+ if ( item . callee ) {
662+ return 'arguments' ;
663+ }
664+ else if ( item [ 'item' ] ) {
665+ return 'collection' ;
666+ }
667+ else {
668+ return 'array' ;
669+ }
670+ }
671+
672+ return 'object' ;
673+ }
674+ else if ( type === 'function' ) {
675+ return Type . isConstructor ( item ) ? 'constructor' : 'function' ;
676+ }
677+ else {
678+ return type ;
679+ }
680+ } ; // }}}
681+ }
627682
628683Type . isRegex = Type . isRegExp ;
629684
0 commit comments