'use strict';

var objects = require('./objects.js');


function type(val) {
    // does an end-around on primitives by converting them to objects
    // tries to find subtype for objects
    if ( val === undefined ) {
        return {'type': 'undefined', 'prototypes': [],
                'subtype': undefined, 'isPrimitive': true};
    } else if ( val === null ) {
        return {'type': 'null', 'prototypes': [],
                'subtype': undefined, 'isPrimitive': true};
    }
    var ps = objects.prototypes(val);
    return {
        'type': 'object', 
        'prototypes': ps, 
        'subtype': ps[0].constructor.name,
        'isPrimitive': !(val instanceof Object)
    };
}

function isArray(val) {
    return val instanceof Array;
}

function isArguments(val) {
    return Object.prototype.toString.call(obj) === '[object Arguments]';
}


module.exports = {
    'type':  type,
    'isArray': isArray,
    'isArguments': isArguments
};


@@ -290,33 +290,28 @@
  'subtype': 
-undefined
+null
 , 'isPrimiti
@@ -432,25 +432,20 @@
 btype': 
-undefined
+null
 , 'isPri
@@ -589,16 +589,34 @@
 ubtype':
+ (ps.length %3E 0) ?
  ps%5B0%5D.c
@@ -630,16 +630,23 @@
 tor.name
+ : null
 ,%0A      

deal with corner case for Object.prototype (since it doesn't have a prototype -- is it the only one?); use null instead of undefined where subtypes are missing