From 8534b32a9f29314cd54b8399e6d97f2e71c49493 Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Fri, 27 Jan 2023 15:47:23 +1100 Subject: [PATCH] Tidy up runtime JS --- v3/internal/runtime/desktop/calls.js | 12 ++++++------ v3/internal/runtime/desktop/ipc.js | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/v3/internal/runtime/desktop/calls.js b/v3/internal/runtime/desktop/calls.js index 161aaaed6..716ee2596 100644 --- a/v3/internal/runtime/desktop/calls.js +++ b/v3/internal/runtime/desktop/calls.js @@ -17,7 +17,7 @@ export const callbacks = {}; * @returns number */ function cryptoRandom() { - var array = new Uint32Array(1); + let array = new Uint32Array(1); return window.crypto.getRandomValues(array)[0]; } @@ -32,7 +32,7 @@ function basicRandom() { } // Pick a random number function based on browser capability -var randomFunc; +let randomFunc; if (window.crypto) { randomFunc = cryptoRandom; } else { @@ -67,12 +67,12 @@ export function Call(name, args, timeout) { return new Promise(function (resolve, reject) { // Create a unique callbackID - var callbackID; + let callbackID; do { callbackID = name + '-' + randomFunc(); } while (callbacks[callbackID]); - var timeoutHandle; + let timeoutHandle; // Set timeout if (timeout > 0) { timeoutHandle = setTimeout(function () { @@ -115,12 +115,12 @@ window.ObfuscatedCall = (id, args, timeout) => { return new Promise(function (resolve, reject) { // Create a unique callbackID - var callbackID; + let callbackID; do { callbackID = id + '-' + randomFunc(); } while (callbacks[callbackID]); - var timeoutHandle; + let timeoutHandle; // Set timeout if (timeout > 0) { timeoutHandle = setTimeout(function () { diff --git a/v3/internal/runtime/desktop/ipc.js b/v3/internal/runtime/desktop/ipc.js index 8543cf59a..0947e822b 100644 --- a/v3/internal/runtime/desktop/ipc.js +++ b/v3/internal/runtime/desktop/ipc.js @@ -16,7 +16,7 @@ let postMessage = null; (function () { // Credit: https://stackoverflow.com/a/2631521 let _deeptest = function (s) { - var obj = window[s.shift()]; + let obj = window[s.shift()]; while (obj && s.length) obj = obj[s.shift()]; return obj; };