Procházet zdrojové kódy

added DEBUG constant

Gildas před 7 roky
rodič
revize
09f8c7d912
1 změnil soubory, kde provedl 24 přidání a 7 odebrání
  1. 24 7
      lib/single-file/single-file-core.js

+ 24 - 7
lib/single-file/single-file-core.js

@@ -22,6 +22,7 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 
 	const SELECTED_CONTENT_ATTRIBUTE_NAME = "data-single-file-selected-content";
 	const SELECTED_CONTENT_ROOT_ATTRIBUTE_NAME = "data-single-file-selected-content-root";
+	const DEBUG = false;
 
 	let Download, DOM, URL, sessionId = 0;
 
@@ -181,21 +182,37 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 		}
 
 		async executeStage(step) {
+			if (DEBUG) {
+				console.log("-- STARTED STAGE --", step); // eslint-disable-line no-console
+			}
 			STAGES[step].sync.forEach(task => {
-				// const startTime = Date.now();
-				// console.log(task.action, "...");
+				let startTime;
+				if (DEBUG) {
+					startTime = Date.now();
+					console.log("STARTED", task.action); // eslint-disable-line no-console
+				}
 				this.executeTask(task, !step);
-				// console.log(task.action, Date.now() - startTime);
+				if (DEBUG) {
+					console.log("ENDED", task.action, Date.now() - startTime); // eslint-disable-line no-console
+				}
 			});
 			if (STAGES[step].async) {
-				return Promise.all(STAGES[step].async.map(task => {
-					// const startTime = Date.now();
-					// console.log(task.action, "...");
+				return await Promise.all(STAGES[step].async.map(task => {
+					let startTime;
+					if (DEBUG) {
+						startTime = Date.now();
+						console.log("STARTED", task.action, "..."); // eslint-disable-line no-console
+					}
 					const promise = this.executeTask(task, !step);
-					// promise.then(() => console.log(task.action, Date.now() - startTime));
+					if (DEBUG) {
+						promise.then(() => console.log("ENDED", task.action, Date.now() - startTime)); // eslint-disable-line no-console
+					}
 					return promise;
 				}));
 			}
+			if (DEBUG) {
+				console.log("-- ENDED STAGE --", step); // eslint-disable-line no-console
+			}
 		}
 
 		executeTask(task, initialization) {