fp.js
/**
   * Returns unified array with or without duplicates.
   * @param list1 {Array} first array
   * @param list2 {Array} second array
   * @param duplicate {boolean} boolean to include duplicates
   * @returns {Array} array with/without duplicates
   */
Returns unified array with or without duplicates.
@param list1 {Array} first array
@param list2 {Array} second array
@param duplicate {boolean} boolean to include duplicates
@returns {Array} array with/without duplicates
Returns unified array with or without duplicates . @param list1 { Array } first array @param list2 { Array } second array @param duplicate { boolean } boolean to include duplicates @returns { Array } array with / without duplicates
function union(list1, list2, duplicate=false) {
    if ( arguments.length < 2 ) {
      let args1 = arguments;
      return (...args2) => union(...args1, ...args2);
    } else if (arguments.length === 2 && (! Array.isArray(list2))) {
      let args = arguments;
      return (list) => union(list, ...args);
    }
    if(duplicate) {
      return differenceWithDup([],list1.concat(list2));
    }
    return difference([],list1.concat(list2));
  }
function union ( list1 , list2 , duplicate = false ) { if ( arguments . length < 2 ) { let args1 = arguments ; return ( ... args2 ) => union ( ... args1 , ... args2 ) ; } else if ( arguments . length === 2 && ( ! Array . isArray ( list2 ) ) ) { let args = arguments ; return ( list ) => union ( list , ... args ) ; } if ( duplicate ) { return differenceWithDup ( [ ] , list1 . concat ( list2 ) ) ; } return difference ( [ ] , list1 . concat ( list2 ) ) ; }
Returns unified array with or without duplicates.
Returns unified array with or without duplicates .
// Manually currying // curring union(_, list, duplicate) cases // Manually currying