5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 22:13:36 +08:00

Tidy up runtime JS

This commit is contained in:
Lea Anthony 2023-01-27 15:47:23 +11:00
parent 368f0e48bc
commit 8534b32a9f
No known key found for this signature in database
GPG Key ID: 33DAF7BB90A58405
2 changed files with 7 additions and 7 deletions

View File

@ -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 () {

View File

@ -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;
};