JSFiddle - React, Tailwind, and code Playground

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.min.js"></script>

JavaScript

const isFlattenable = (v) => Array.isArray(v) /*|| isArguments(v)*/ ||
  !!(Symbol.isConcatSpreadable && v && v[Symbol.isConcatSpreadable]);
function doFlat(a, depth, predicate, r = []) {
  const L = a.length;
  const hasPred = typeof predicate === 'function';
  for (let i = 0; i < L; i++) {
    if (hasPred && !predicate(a[i], i, a)) { continue }
    if (depth < 1 || !isFlattenable(a[i])) { r[r.length] = a[i]; continue }
    depth > 1 ? this(depth - 1, predicate, r, a[i]) : r.push(...a[i]);
  }
  return r
}
function _it(iteratee) {
	if (typeof iteratee === 'string' && iteratee.length) {
  	const p = iteratee; // TODO JSON pointer
  	return function(v, i, a) { return !this.has(v[p]) && this.add(v[p]) }
  } else if (typeof iteratee === 'function') {
  	return function(v, i, a) {
    	const r = iteratee(v, i, a);
      return typeof r !== 'undefined' && !this.has(r) && this.add(r)
    }
  }
}

// Difference, Union, Intersection
function DUI(a, b, type = 'D', iteratee = false, comparator = false, INTER = []) {
	const A = new Set(); 
	if (!iteratee && !comparator) {
    const _M = type === 'D' ? 'delete' : 'add';
    const AL = a.length, BL = b.length;
    for(var i = 0; i<AL; i++) { A.add(a[i]) }
    for(var i = 0; i<BL; i++) {
      (type === 'I' && A.has(b[i])) ? INTER.push(b[i]) : A[_M](b[i]);
    }
    return type === 'I' ? INTER : [...A]
  }
  const _last = b[b.length - 1];
  if (typeof _last === 'function') {
  	iteratee ? (iteratee = b.splice(-1)[0]) : (comparator = b.splice(-1)[0]);
    b = doFlat(b, 1)
  }
	if (type === 'U') { a = Array.from(new Set(a)) }
	const AL = a.length; const BL = b.length;
  const B = new Set();
  let R = [];
  if (iteratee) {
  	for (let i = 0; i < BL; i++) {
      if (type !== 'U') { b[i] = iteratee(b[i]); continue }
    	const v = iteratee(b[i]);
      if (!A.has(v)) { R.push(b[i]) }
      A.add(b[i]);
    }
  }
/*  if (comparator) {
    includes = arrayIncludesWith
//    isCommon = false
  } */
  for (let i = 0; i < BL; i++) {...