import { Pipe, PipeTransform } from '@angular/core';
import { groupBy } from '../defs/group-by';

@Pipe({
  name: 'groupBy',
})
export class GroupByPipe implements PipeTransform {
  transform(value: [], selectGroup: (item: any) => any): any {
    if (typeof selectGroup !== 'function') {
      console.warn(`Function selectGroup is required.`);
      return [];
    }
    return groupBy(value, selectGroup);
  }
}
