Add loadFile method

This commit is contained in:
Sam Carlton 2022-08-21 08:42:32 -05:00
parent c883fe85d6
commit 3f238dfd4e

View file

@ -103,6 +103,24 @@ export class AppScan {
) )
} }
async loadFile () {
// If fileLoader is no a function
// then try to load the file
if ( typeof( this.fileLoader ) !== 'function' ) {
return this.fileLoader
}
const file = this.fileLoader()
// Check if our file is a Promise
// if it is then await it
if ( file instanceof Promise || typeof file?.then === 'function' ) {
return await file
}
return file
}
async readFileBlob ( FileInstance ) { async readFileBlob ( FileInstance ) {
return new Promise( async ( resolve, reject ) => { return new Promise( async ( resolve, reject ) => {