From 3f238dfd4e253adc89f347dde0771b708a9aa614 Mon Sep 17 00:00:00 2001 From: Sam Carlton Date: Sun, 21 Aug 2022 08:42:32 -0500 Subject: [PATCH] Add loadFile method --- helpers/scanner/scan.mjs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/helpers/scanner/scan.mjs b/helpers/scanner/scan.mjs index 863fd0a..e6bc6de 100644 --- a/helpers/scanner/scan.mjs +++ b/helpers/scanner/scan.mjs @@ -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 ) { return new Promise( async ( resolve, reject ) => {