import toDate from '../toDate/index' ; import requiredArgs from '../_lib/requiredArgs/index' ; name category summary description param { Date [ ] | Number [ ] } datesArray returns { Date } throws example export default function min ( dirtyDatesArray ) { requiredArgs ( 1 , arguments ) ; let datesArray ; if ( dirtyDatesArray && typeof dirtyDatesArray . forEach === 'function' ) { datesArray = dirtyDatesArray ; } else if ( typeof dirtyDatesArray === 'object' && dirtyDatesArray !== null ) { datesArray = Array . prototype . slice . call ( dirtyDatesArray ) ; } else { return new Date ( NaN ) ; } let result ; datesArray . forEach ( function ( dirtyDate ) { let currentDate = toDate ( dirtyDate ) ; if ( result === undefined || result > currentDate || isNaN ( currentDate . getDate ( ) ) ) { result = currentDate ; } } ) ; return result || new Date ( NaN ) ; }