All files / array remove.ts

93.33% Statements 14/15
83.33% Branches 5/6
100% Functions 1/1
93.33% Lines 14/15

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 241x     2x 2x     2x 2x 2x   2x 8x 8x 5x 5x     2x 2x     1x  
import { basePullAt } from '../_internal/basePullAt';
 
function remove(array: string | any[], predicate: (arg0: any, arg1: number, arg2: any) => any) {
  const result: any[] = [];
  Iif (!(array && array.length)) {
    return result;
  }
  let index = -1,
    indexes = [],
    length = array.length;
 
  while (++index < length) {
    const value = array[index];
    if (predicate(value, index, array)) {
      result.push(value);
      indexes.push(index);
    }
  }
  basePullAt(array, indexes)
  return result;
}
 
export { remove }