'use strict';

var isArray;
if (typeof Array.isArray === 'undefined') {
	isArray = function (arg) {
		return Object.prototype.toString.call(arg) === '[object Array]';
	};
} else {
	isArray = Array.isArray;
}

var transforms = {
	'none': function(key) {
		return key;
	},

	'camel-case': function(key) {
		var parts = key.toLowerCase().split('_');
		var part;

		for (var idx = 0, len = parts.length; idx < len; idx++) {
			part = parts[idx];
			part = part.substr(0, 1).toUpperCase() + part.substr(1);

			parts[idx] = part;
		}

		return parts.join("");
	},

	'lower-case': function(key) {
		return key.toLowerCase();
	},

	'dashed': function(key) {
		return key.replace(/_/g, '-');
	},

	'lower-dashed': function(key) {
		return this['lower-case'](this['dashed'](key));
	}
};

var transformNames = [];
for (var transformName in transforms) {
	transformNames.push(transformName);
}

module.exports = function(obj, transformType) {
	if (obj === null || (typeof obj !== 'object' && isArray(obj) === false)) {
		throw 'The first argument to mirrorKey must be a object or an array.';
	}

	if (typeof transformType === 'undefined') {
		transformType = 'none';
	} else {
		if (transformNames.indexOf(transformType) === -1) {
			throw 'Unknown value for transformType. Valid values: ' + transformNames.join(', ');
		}
	}

	var result = {};

	for (var key in obj) {
		if (obj.hasOwnProperty(key) === false) {
			continue;
		}

		result[key] = transforms[transformType](key);
	}

	return result;
};
@@ -925,16 +925,49 @@
 Type) %7B%0A
+%09var objIsArray = isArray(obj);%0A%0A
 %09if (obj
@@ -1007,28 +1007,26 @@
 ect' && 
-i
+objI
 sArray
-(obj)
  === fal
@@ -1359,16 +1359,46 @@
  = %7B%7D;%0A%0A
+%09if (objIsArray === false) %7B%0A%09
 %09for (va
@@ -1413,16 +1413,17 @@
  obj) %7B%0A
+%09
 %09%09if (ob
@@ -1457,16 +1457,17 @@
 alse) %7B%0A
+%09
 %09%09%09conti
@@ -1469,27 +1469,29 @@
 continue;%0A%09%09
+%09
 %7D%0A%0A
+%09
 %09%09result%5Bkey
@@ -1526,16 +1526,124 @@
 %5D(key);%0A
+%09%09%7D%0A%09%7D else %7B%0A%09%09for (var idx = 0, len = obj.length; idx %3C len; idx++) %7B%0A%09%09%09result%5Bobj%5Bidx%5D%5D = obj%5Bidx%5D;%0A%09%09%7D%0A
 %09%7D%0A%0A%09ret

Handle arrays