export interface FileResult { lastModifiedDate : string | undefined ; lastModified : number ; name : string ; size : number ; type : string ; src : string | ArrayBuffer | null ; } export function readFile ( file ) { return new Promise ( ( resolve ) => { const reader = new FileReader ( ) ; reader . onload = ( event ) => { resolve ( { lastModifiedDate : file . lastModifiedDate , lastModified : file . lastModified , name : file . name , size : file . size , type : file . type , src : event . target ! . result , } ) ; } ; if ( file . type . indexOf ( 'text/' ) === 0 || file . type === 'application/json' ) { reader . readAsText ( file ) ; } else if ( file . type . indexOf ( 'image/' ) === 0 ) { reader . readAsDataURL ( file ) ; } else { reader . readAsBinaryString ( file ) ; } } ) ; } export function readFiles ( files ) { return Promise . all ( files . map ( readFile ) ) ; }