import { WeekDay } from '@angular/common' ; import { Pipe , PipeTransform } from '@angular/core' ; @ Pipe ( { name : 'weekDaySort' } ) export class WeekDaySortPipe implements PipeTransform { transform ( value , startOfWeek ) { startOfWeek = Math . max ( WeekDay . Sunday , Math . min ( WeekDay . Saturday , startOfWeek ) ) ; const weekdays = [ ... value ] ; for ( let idx = 0 ; idx < startOfWeek ; idx ++ ) { weekdays . push ( weekdays . shift ( ) ) ; } return weekdays ; } }