/**
 * Filters the passed value and returns `undefined` if either:
 * – An [array] or an {object} is empty.
 * – `null` has been passed.
 * – `NaN` has been passed.
 *
 * @flow
 * @param {*} a – The passed data.
 * @return {*|undefined} – Either `undefined` or the passed data.
 */

function filterEmpty(a: mixed): mixed {
  if (typeof a === "object") {
    // typeof null => "object"
    if (a === null) return undefined;

    return Object.keys(a).length > 0 ? a : undefined;
  }
  
  // isNaN("a") => true
  // Number.isNaN("a") => false
  if (Number.isNaN(a)) return undefined;

  return a;
}

export { filterEmpty };
@@ -425,120 +425,217 @@
     
-return Object.keys(a).length %3E 0 ? a : undefined;%0A  %7D%0A  %0A  // isNaN(%22a%22) =%3E true%0A  // Number.isNaN(%22a%22) =%3E false
+// Get the first key, reassign it and break the loop%0A    // If there are no keys, it doesn't do anything%0A    let key = undefined;%0A    for (key in a) break;%0A%0A    return key !== undefined ? a : undefined;%0A  %7D%0A  
 %0A  i

Optimize filterEmpty