fp.js
/**
   * Drops specified number of values from array either through left or right.
   * Uses passed in function to filter remaining array after values dropped.
   * Default dropCount = 1
   */
Drops specified number of values from array either through left or right.
Uses passed in function to filter remaining array after values dropped.
Default dropCount = 1
Drops specified number of values from array either through left or right . Uses passed in function to filter remaining array after values dropped . Default dropCount = 1
function drop(list,dropCount=1,direction="left",fn=null) {
    if (!(list && Array.isArray(list))) {
      let args = arguments;
      return (list) => drop(list, ...args);
    }
    if(dropCount === 0 && !fn) {
      return Array.prototype.slice.call(list, 0)
    };
    if(arguments.length === 1 || direction === "left") {
      if (!fn) {
        return Array.prototype.slice.call(list, +dropCount);
      }
      return (Array.prototype.slice.call(list, +dropCount)).filter(x=>fn(x));
    }
    if(direction === "right"){
      if(!fn) {
        return Array.prototype.slice.call(list, 0, list.length-(+dropCount));
      }
      if(dropCount === 0) {return (Array.prototype.slice.call(list, 0)).filter(x=>fn(x))};
      return (Array.prototype.slice.call(list, 0, list.length-(+dropCount))).filter(x=>fn(x));
    }
  }
function drop ( list , dropCount = 1 , direction = "left" , fn = null ) { if ( ! ( list && Array . isArray ( list ) ) ) { let args = arguments ; return ( list ) => drop ( list , ... args ) ; } if ( dropCount === 0 && ! fn ) { return Array . prototype . slice . call ( list , 0 ) } ; if ( arguments . length === 1 || direction === "left" ) { if ( ! fn ) { return Array . prototype . slice . call ( list , + dropCount ) ; } return ( Array . prototype . slice . call ( list , + dropCount ) ) . filter ( x => fn ( x ) ) ; } if ( direction === "right" ) { if ( ! fn ) { return Array . prototype . slice . call ( list , 0 , list . length - ( + dropCount ) ) ; } if ( dropCount === 0 ) { return ( Array . prototype . slice . call ( list , 0 ) ) . filter ( x => fn ( x ) ) } ; return ( Array . prototype . slice . call ( list , 0 , list . length - ( + dropCount ) ) ) . filter ( x => fn ( x ) ) ; } }
Drops specified number of values from array either through left or right.
Drops specified number of values from array either through left or right .
// If the first argument is not kind of `array`-like. // Manually currying