"use strict";

var _ = require('lodash');

module.exports = function (data, options) {
	options = _.extend({
		compress: false
	}, options);

	var comma = options.compress ? ',': ', ';
	var arrow = options.compress ? '=>': ' => ';

	var convert = function (obj) {
		switch (Object.prototype.toString.call(obj)) {
			case '[object Boolean]':
				return obj ? 'true' : 'false';
			case '[object String]':
				return '"' + obj.replace(/\\/g, '\\\\').replace(/\"/g, '\\"') + '"';
			case '[object Number]':
				return String(obj);
			case '[object Array]':
				return 'array(' +
					obj.map(convert).join(comma) +
				')';
			case '[object Object]':
				return 'array(' +
					_.map(obj, function (v, k) {
						return '"' + k + '"' + arrow + convert(v);
					}).join(comma) +
				')';
		}

		return 'null';
	};

	data = JSON.parse(JSON.stringify(data)); // remove non-JSON properties

	return convert(data);
};
@@ -151,32 +151,8 @@
 ma =
- options.compress ? ',':
  ', 
@@ -167,16 +167,30 @@
 arrow = 
+' =%3E ';%0A%0A%09if (
 options.
@@ -201,24 +201,62 @@
 ress
- ? '=%3E': ' =%3E ';
+) %7B%0A%09%09arrow = arrow.trim();%0A%09%09comma = comma.trim();%0A%09%7D
 %0A%0A%09v

move compress condition to separate if