import { isObject , isString } from '../../utils/validate' ; import type { Images , ImageObject } from '../PropsType' ; import LOAD_STATUS from './loadStatus' ; function isImageString ( image ) { return isString ( image ) ; } function isImageObject ( image ) { return isObject ( image ) ; } const formatImages = ( images ) : Images => { const previewImages = [ ] ; ( images || [ ] ) . forEach ( ( image ) => { if ( isImageString ( image ) ) { previewImages . push ( { url : image , } ) ; } else if ( isImageObject ( image ) ) { previewImages . push ( { url : image . url , originUrl : image . originUrl , loaded : LOAD_STATUS . before , } ) ; } } ) ; return previewImages ; } ; export default formatImages ;