5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-03 10:41:14 +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 * @returns number
*/ */
function cryptoRandom() { function cryptoRandom() {
var array = new Uint32Array(1); let array = new Uint32Array(1);
return window.crypto.getRandomValues(array)[0]; return window.crypto.getRandomValues(array)[0];
} }
@ -32,7 +32,7 @@ function basicRandom() {
} }
// Pick a random number function based on browser capability // Pick a random number function based on browser capability
var randomFunc; let randomFunc;
if (window.crypto) { if (window.crypto) {
randomFunc = cryptoRandom; randomFunc = cryptoRandom;
} else { } else {
@ -67,12 +67,12 @@ export function Call(name, args, timeout) {
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
// Create a unique callbackID // Create a unique callbackID
var callbackID; let callbackID;
do { do {
callbackID = name + '-' + randomFunc(); callbackID = name + '-' + randomFunc();
} while (callbacks[callbackID]); } while (callbacks[callbackID]);
var timeoutHandle; let timeoutHandle;
// Set timeout // Set timeout
if (timeout > 0) { if (timeout > 0) {
timeoutHandle = setTimeout(function () { timeoutHandle = setTimeout(function () {
@ -115,12 +115,12 @@ window.ObfuscatedCall = (id, args, timeout) => {
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
// Create a unique callbackID // Create a unique callbackID
var callbackID; let callbackID;
do { do {
callbackID = id + '-' + randomFunc(); callbackID = id + '-' + randomFunc();
} while (callbacks[callbackID]); } while (callbacks[callbackID]);
var timeoutHandle; let timeoutHandle;
// Set timeout // Set timeout
if (timeout > 0) { if (timeout > 0) {
timeoutHandle = setTimeout(function () { timeoutHandle = setTimeout(function () {

View File

@ -16,7 +16,7 @@ let postMessage = null;
(function () { (function () {
// Credit: https://stackoverflow.com/a/2631521 // Credit: https://stackoverflow.com/a/2631521
let _deeptest = function (s) { let _deeptest = function (s) {
var obj = window[s.shift()]; let obj = window[s.shift()];
while (obj && s.length) obj = obj[s.shift()]; while (obj && s.length) obj = obj[s.shift()];
return obj; return obj;
}; };