// const _typeof =
// 	typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol'
// 		? function (obj) {
// 			return typeof obj;
// 		  }
// 		: function (obj) {
// 			return obj &&
// 					typeof Symbol === 'function' &&
// 					obj.constructor === Symbol
// 				? 'symbol'
// 				: typeof obj;
// 		  };

const { diff } = require('deep-diff');
const _ = require('lodash');

exports.default = {
	test: function test() {
		return true;
	},
	calcDelta: function calcDelta(current, next, exclude, strict) {
		const DEBUG = false;
		if (DEBUG) {
			console.log('current', current);
			console.log('next', next);
			console.log('exclude', exclude);
		}

		const di = diff(current, next);

		if (DEBUG) {
			console.log('di', di);

			const diffs2 = di
				? di.map(i =>
					JSON.parse(JSON.stringify(i).replace('"__data",', '')),
				  )
				: [];
			console.log('diffs2', diffs2);

			console.log(
				'filter1',
				diffs2.filter(i => i.path.join(',').indexOf('_') === -1),
			);

			console.log(
				'filter2',
				diffs2.filter(i =>
					exclude.every(x => i.path.indexOf(x) === -1),
				),
			);
		}

		const diffs = di
			? di
				.map(i =>
					JSON.parse(JSON.stringify(i).replace('"__data",', '')),
				)
				.filter(i => {
					if (!strict && i.kind === 'E') {
						if (i.lhs !== i.rhs) return i;
					} else return i;
					return false;
				})
				.filter(i => exclude.every(x => i.path.indexOf(x) === -1))
			: [];
		if (diffs.length > 0) {
			return diffs;
		}
		return null;
	},
	capitalizeFirstLetter(string) {
		return string.charAt(0).toUpperCase() + string.slice(1);
	},
	diffToString: function diffToString(val) {
		if (typeof val === 'undefined' || val === null) {
			return '';
		}
		if (val === true) {
			return '1';
		}
		if (val === false) {
			return '0';
		}
		if (typeof val === 'string') {
			return val;
		}
		if (!isNaN(val)) {
			return `${String(val)}`;
		}
		if (
			(typeof val === 'undefined' ? 'undefined' : typeof val) === 'object'
		) {
			return `${JSON.stringify(val)}`;
		}
		if (Array.isArray(val)) {
			return `${JSON.stringify(val)}`;
		}
		return '';
	},
	toUnderscored: function toUnderscored(obj) {
		_.forEach(obj, (k, v) => {
			obj[k] = v
				.replace(/(?:^|\.?)([A-Z])/g, (x, y) => `_${y.toLowerCase()}`)
				.replace(/^_/, '');
		});
		return obj;
	},
};
module.exports = exports.default;

@@ -734,20 +734,18 @@
 i);%0A%0A%09%09%09
-cons
+le
 t diffs2
@@ -751,16 +751,37 @@
 2 = 
-di%0A%09%09%09%09?
+%5B%5D;%0A%09%09%09if (di) %7B%0A%09%09%09%09diffs2 =
  di.
@@ -858,21 +858,16 @@
 %09%09%09%09
-  
 )
+;
 %0A%09%09%09
-%09: %5B%5D;
+%7D%0A
 %0A%09%09%09
@@ -1119,28 +1119,26 @@
 %09%09);%0A%09%09%7D%0A%0A%09%09
-cons
+le
 t diffs = di
@@ -1139,15 +1139,34 @@
 s = 
-di%0A%09%09%09?
+%5B%5D;%0A%09%09if (di) %7B%0A%09%09%09diffs =
  di%0A
@@ -1265,16 +1265,362 @@
 (i =%3E %7B%0A
+%09%09%09%09%09// return i.path.join(%22,%22).indexOf(%22_%22) === -1;%0A%09%09%09%09%09// console.log('i', i)%0A%09%09%09%09%09// if (!strict && i.kind === 'E') %7B%0A%09%09%09%09%09// %09// console.log('str & num', i.lhs == i.rhs)%0A%09%09%09%09%09// %09// console.log('str & num (strict)', i.lhs === i.rhs)%0A%09%09%09%09%09// %09if (i.lhs != i.rhs) %7B%0A%09%09%09%09%09// %09%09return i;%0A%09%09%09%09%09// %09%7D%0A%09%09%09%09%09// %7D else %7B%0A%09%09%09%09%09// %09return i;%0A%09%09%09%09%09// %7D%0A
 %09%09%09%09%09if 
@@ -1800,17 +1800,14 @@
 -1))
+;
 %0A%09%09
-%09: %5B%5D;
+%7D%0A
 %0A%09%09i
@@ -2225,19 +2225,34 @@
 f (!
-isNaN
+Number.isNaN(Number
 (val))
+)
  %7B%0A%09

improve readability