var DEBUG = 1;

/* ====================
         Shims
   ==================== */
if (!String.prototype.contains) {
	String.prototype.contains = function (text) {
		return this.indexOf(text) !== -1;
	};
}

/* ====================
     General utils
   ==================== */
function log() {
	console.log(...arguments);
	return arguments.length === 1 ? arguments[0] : _.toArray(arguments);
}

function warn() {
	console.warn(...arguments);
	debugger;
	return arguments.length === 1 ? arguments[0] : _.toArray(arguments);
}

function err(ErrorType, ...args) {
	if (!ErrorType) {
		console.error(...args);
	} else {
		throw new ErrorType(args.join(' '));
	}
	return args.length === 1 ? args[0] : _.toArray(args);
}

// Build an index on an array based on an object property.
// Assumes that arr contains objects that have unique keys
// Updates to objects that don't modify the key will NOT invalidate the index
// Adding / removing elements to the array or changing keys after building the index will NOT be reflected
function buildIndexHash(arr, prop) {
	return _.pluck(arr, prop)
		.reduce(function (indexObject, currentKey, currentIndex) {
			indexObject[currentKey] = arr[currentIndex];
			return indexObject;
		}, {});
}

/* ====================
      Workout utils
   ==================== */

/**
 * Round num to nearestY
 * @param {Number} nearestNum
 * @param {Number} num
 * @return {Number}
 */
function roundTo(nearestNum, num) {
	return Math.round(num / nearestNum) * nearestNum;
}

const lowestPlate = 2.5; // TODO: get from cfg
var round = _.curry(roundTo)(lowestPlate * 2);

@@ -282,16 +282,23 @@
 ion log(
+...args
 ) %7B%0A%09con
@@ -308,29 +308,24 @@
 e.log(...arg
-ument
 s);%0A%09return 
@@ -319,37 +319,32 @@
 gs);%0A%09return arg
-ument
 s.length === 1 ?
@@ -351,40 +351,19 @@
  arg
-ument
 s%5B0%5D : 
-_.toArray(arguments)
+args
 ;%0A%7D%0A
@@ -377,16 +377,23 @@
 on warn(
+...args
 ) %7B%0A%09con
@@ -408,21 +408,16 @@
 n(...arg
-ument
 s);%0A%09deb
@@ -434,21 +434,16 @@
 turn arg
-ument
 s.length
@@ -458,40 +458,19 @@
  arg
-ument
 s%5B0%5D : 
-_.toArray(arguments)
+args
 ;%0A%7D%0A
@@ -644,23 +644,12 @@
 %5D : 
-_.toArray(
 args
-)
 ;%0A%7D%0A

clean up log/warn/err helpers