From 046a39c4f37f8fb59fd98f5245c24eed0f4441db Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Mon, 9 Sep 2024 14:46:27 -0700 Subject: [PATCH] Modernize JS usage in library_pthread.js. NFC --- src/library_pthread.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/library_pthread.js b/src/library_pthread.js index 956413960afb3..770139140b109 100644 --- a/src/library_pthread.js +++ b/src/library_pthread.js @@ -75,7 +75,7 @@ var LibraryPThread = { ) { t = _pthread_self(); } - return 'w:' + workerID + ',t:' + ptrToString(t) + ': '; + return `w:${workerID},t:${ptrToString(t)}: `; } // Prefix all err()/dbg() messages with the calling thread ID. @@ -426,7 +426,7 @@ var LibraryPThread = { #if EXPORT_ES6 && USE_ES6_IMPORT_META // If we're using module output, use bundler-friendly pattern. #if PTHREADS_DEBUG - dbg('Allocating a new web worker from ' + import.meta.url); + dbg(`Allocating a new web worker from ${import.meta.url}`); #endif #if TRUSTED_TYPES // Use Trusted Types compatible wrappers. @@ -738,10 +738,10 @@ var LibraryPThread = { #endif var offscreenCanvases = {}; // Dictionary of OffscreenCanvas objects we'll transfer to the created thread to own - var moduleCanvasId = Module['canvas'] ? Module['canvas'].id : ''; + var moduleCanvasId = Module['canvas']?.id || ''; // Note that transferredCanvasNames might be null (so we cannot do a for-of loop). - for (var i in transferredCanvasNames) { - var name = transferredCanvasNames[i].trim(); + for (var name of transferredCanvasNames) { + name = name.trim(); var offscreenCanvasInfo; try { if (name == '#canvas') { @@ -773,7 +773,7 @@ var LibraryPThread = { } if (canvas.transferControlToOffscreen) { #if GL_DEBUG - dbg('pthread_create: canvas.transferControlToOffscreen(), transferring canvas by name "' + name + '" (DOM id="' + canvas.id + '") from main thread to pthread'); + dbg(`pthread_create: canvas.transferControlToOffscreen(), transferring canvas by name "${name}" (DOM id="${canvas.id}") from main thread to pthread`); #endif // Create a shared information block in heap so that we can control // the canvas size from any thread.