'use strict';

var util = require('./lib/util');
var primitives = /undefined|null|string|number|boolean|symbol/;

function Type(src){
  if(!(this instanceof Type)){
    return new Type(src);
  }

  var strRep, classType = util.getClassType(src);
  this[classType] = src || Boolean(src + '') || ' ';
  // primitives
  if(primitives.test(classType)) {
    if(this.number){
      strRep = src + '';
      if(parseInt(strRep) === src){
        this.integer = src;
      } else if(/\./.test(strRep)){
        this.float = src;
      } else if(src){
        this.infinity = src;
      } else {
        this.nan = true;
        delete this.number;
      }
    }
    return this;
  }

  // everything else is an object
  var ctorName = (src.constructor.name || '').toLowerCase();
  if(!this.object){
    this.object = src;
  } else if (classType !== ctorName) {
    this[ctorName] = src;
  } else {
    this.plainObject = src;
    return this;
  }

  // exploit the util.inherits pattern
  var super_ = src.constructor.super_;
  while(super_){
    this[super_.name.toLowerCase()] = src;
    super_ = super_.super_;
  }

  return this;
}

Type.prototype.match = function(pattern){
  var types = Object.keys(this);
  var source = this[types[0]];
  if(RegExp(pattern).test(types.join(' '))){
    return source || Boolean(source + '') || ' ';
  }
  return null;
};

exports = module.exports = Type;

@@ -16,36 +16,34 @@
 var 
-util = require('./lib/util')
+__toString = (%7B%7D).toString
 ;%0Ava
@@ -114,17 +114,17 @@
 unction 
-T
+t
 ype(src)
@@ -131,133 +131,147 @@
 %7B%0A  
-if(!(this instanceof Type))%7B%0A    return new Type(src);%0A  %7D%0A%0A  var strRep,
+var strRep;%0A%0A  var self = Object.create(type.proto);%0A  var
  class
-Typ
+Nam
 e = 
-util.getClassType(src
+__toString.call(src).match(/%5Cw+/g)%5B1%5D.toLowerCase(
 );%0A  
-this
+self
 %5Bclass
-Typ
+Nam
 e%5D =
@@ -286,16 +286,25 @@
 Boolean(
+strRep = 
 src + ''
@@ -313,16 +313,17 @@
 %7C%7C ' ';%0A
+%0A
   // pri
@@ -360,15 +360,14 @@
 lass
-Typ
+Nam
 e))
- 
 %7B%0A  
@@ -371,20 +371,20 @@
 %0A    if(
-this
+self
 .number)
@@ -401,23 +401,41 @@
 rRep = s
-rc + ''
+trRep %7C%7C src.toString(10)
 ;%0A      
@@ -472,20 +472,20 @@
         
-this
+self
 .integer
@@ -536,20 +536,20 @@
         
-this
+self
 .float =
@@ -584,20 +584,20 @@
         
-this
+self
 .infinit
@@ -628,20 +628,20 @@
         
-this
+self
 .nan = t
@@ -660,20 +660,20 @@
  delete 
-this
+self
 .number;
@@ -677,24 +677,43 @@
 er;%0A      %7D%0A
+      return self;%0A
     %7D%0A    re
@@ -709,36 +709,36 @@
    %7D%0A    return 
-this
+self
 ;%0A  %7D%0A%0A  // ever
@@ -762,16 +762,37 @@
  object%0A
+  self.object = src;%0A
   var ct
@@ -850,58 +850,8 @@
 ;%0A  
-if(!this.object)%7B%0A    this.object = src;%0A  %7D else 
 if (
@@ -855,19 +855,19 @@
 f (class
-Typ
+Nam
 e !== ct
@@ -880,20 +880,20 @@
 ) %7B%0A    
-this
+self
 %5BctorNam
@@ -911,26 +911,52 @@
  %7D else 
+if(className === 'object')
 %7B%0A    
-this
+self
 .plainOb
@@ -978,20 +978,20 @@
  return 
-this
+self
 ;%0A  %7D%0A%0A 
@@ -1088,20 +1088,20 @@
 _)%7B%0A    
-this
+self
 %5Bsuper_.
@@ -1159,17 +1159,16 @@
 r_;%0A  %7D%0A
-%0A
   return
@@ -1172,18 +1172,18 @@
 urn 
-this
+self
 ;%0A%7D%0A%0A
-T
+t
 ype.
@@ -1191,20 +1191,86 @@
 roto
-type.match =
+ = Object.create(null);%0A%0AObject.defineProperty(type.proto, 'match', %7B%0A  value:
  fun
@@ -1274,16 +1274,22 @@
 function
+ match
 (pattern
@@ -1291,16 +1291,70 @@
 ttern)%7B%0A
+    if(!pattern %7C%7C !pattern.source)%7B return null; %7D%0A  
   var ty
@@ -1384,37 +1384,8 @@
 ;%0A  
-var source = this%5Btypes%5B0%5D%5D;%0A
   if
@@ -1399,16 +1399,23 @@
 (pattern
+.source
 ).test(t
@@ -1422,22 +1422,14 @@
 ypes
-.join(' ')
 ))%7B%0A
+  
     
@@ -1439,51 +1439,40 @@
 urn 
-source %7C%7C Boolean(source + '') %7C%7C ' ';
+this%5Btypes%5B0%5D%5D %7C%7C true;%0A    %7D
 %0A  
-%7D%0A
   re
@@ -1482,17 +1482,22 @@
 n null;%0A
-%7D
+  %7D%0A%7D)
 ;%0A%0Aexpor
@@ -1522,9 +1522,9 @@
 s = 
-T
+t
 ype;

simplify implementation