import eachDayOfInterval from '../eachDayOfInterval/index' ; import isSunday from '../isSunday/index' ; import isWeekend from '../isWeekend/index' ; import type { Interval } from '../types' ; import requiredArgs from '../_lib/requiredArgs/index' ; name category summary description param { Interval } interval - the given interval. See [Interval] https returns { Date [ ] } throws throws throws example export default function eachWeekendOfInterval ( interval ) { requiredArgs ( 1 , arguments ) ; const dateInterval = eachDayOfInterval ( interval ) ; const weekends = [ ] ; let index = 0 ; while ( index < dateInterval . length ) { const date = dateInterval [ index ++ ] ; if ( isWeekend ( date ) ) { weekends . push ( date ) ; if ( isSunday ( date ) ) index = index + 5 ; } } return weekends ; }