fp.js
/**
   * Returns truthy values from an array.
   * When typ is supplied, returns new array of specified type
   */
Returns truthy values from an array.
When typ is supplied, returns new array of specified type
Returns truthy values from an array . When typ is supplied returns new array of specified type
function compact(list,typ) {
    if(arguments.length === 1) {
      if (Array.isArray(list)) {
        return list.filter(x=>x);
      } else {
        typ = list;
        return function (list) {return compact(list, typ)};
      }
    }
    return list.filter(x=> typeof x === typeof typ);
  }
function compact ( list , typ ) { if ( arguments . length === 1 ) { if ( Array . isArray ( list ) ) { return list . filter ( x => x ) ; } else { typ = list ; return function ( list ) { return compact ( list , typ ) } ; } } return list . filter ( x => typeof x === typeof typ ) ; }
Returns truthy values from an array.
Returns truthy values from an array .
// if the only one param is an array // Curry it manually