export function readFileAsBuffer ( file ) { return new Promise ( ( resolve , reject ) => { const reader = new FileReader ( ) ; reader . onload = ( ) => resolve ( reader . result as ArrayBuffer ) ; reader . onerror = e => reject ( e . error ) ; reader . readAsArrayBuffer ( file ) ; } ) ; } export function readFileAsDataURL ( file ) { return new Promise ( ( resolve , reject ) => { const reader = new FileReader ( ) ; reader . onload = ( ) => resolve ( reader . result ) ; reader . onerror = e => reject ( e . error ) ; reader . readAsDataURL ( file ) ; } ) ; } export function getBaseName ( path ) { let base = String ( path ) . substring ( path . lastIndexOf ( '/' ) + 1 ) ; if ( base . lastIndexOf ( '.' ) !== - 1 ) { base = base . substring ( 0 , base . lastIndexOf ( '.' ) ) ; } return base ; } ;