__fixtures__/Filter.js
function filterMatrix(matrix, filter) {
  const filtered = [];
  if (matrix.length === 0) {
    return matrix;
  }
  for (let row = 0; row < matrix.length; row++) {
    if (matrix.length !== 0) {
      for (let column = 0; column < matrix[0].length; column++) {
        const cell = matrix[row][column];
        if (cell && cell.value.includes(filter)) {
          if (!filtered[0]) {
            filtered[0] = [];
          }
          if (filtered[0].length < column) {
            filtered[0].length = column + 1;
          }
          if (!filtered[row]) {
            filtered[row] = [];
          }
          filtered[row][column] = cell;
        }
      }
    }
  }
  return filtered;
}
function filterMatrix(matrix, filter) {
  const filtered = [];
  if (matrix.length === 0) {
    return matrix;
  }
  for (let row = 0; row < matrix.length; row++) {
    if (matrix.length !== 0) {
      for (let column = 0; column < matrix[0].length; column++) {
        const cell = matrix[row][column];
        if (cell && cell.value.includes(filter)) {
          if (!filtered[0]) {
            filtered[0] = [];
          }
          if (filtered[0].length < column) {
            filtered[0].length = column + 1;
          }
          if (!filtered[row]) {
            filtered[row] = [];
          }
          filtered[row][column] = cell;
        }
      }
    }
  }
  return filtered;
}
function filterMatrix ( matrix , filter ) { const filtered = [ ] ; if ( matrix . length === 0 ) { return matrix ; } for ( let row = 0 ; row < matrix . length ; row ++ ) { if ( matrix . length !== 0 ) { for ( let column = 0 ; column < matrix [ 0 ] . length ; column ++ ) { const cell = matrix [ row ] [ column ] ; if ( cell && cell . value . includes ( filter ) ) { if ( ! filtered [ 0 ] ) { filtered [ 0 ] = [ ] ; } if ( filtered [ 0 ] . length < column ) { filtered [ 0 ] . length = column + 1 ; } if ( ! filtered [ row ] ) { filtered [ row ] = [ ] ; } filtered [ row ] [ column ] = cell ; } } } } return filtered ; }
Removes cells not matching the filter from matrix while maintaining the
minimum size that includes all of the matching cells.
Removes cells not matching the filter from matrix while maintaining the minimum size that includes all of the matching cells .