mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 11:40:56 +08:00
Tidy up runtime JS
This commit is contained in:
parent
368f0e48bc
commit
8534b32a9f
@ -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 () {
|
||||
|
@ -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;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user