From f4868e024b9afa0051917eb91ced1b6dfd5f0da5 Mon Sep 17 00:00:00 2001 From: Blake Vandercar Date: Tue, 7 May 2024 17:17:02 -0600 Subject: [PATCH] style: default --- src/spoof.ts | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/spoof.ts b/src/spoof.ts index 15dc5ce..c16e62f 100644 --- a/src/spoof.ts +++ b/src/spoof.ts @@ -84,7 +84,7 @@ export interface GhostCursor { // Helper function to wait a specified number of milliseconds const delay = async (ms: number): Promise => { if (ms < 1) return - await new Promise((resolve) => setTimeout(resolve, ms)) + return await new Promise((resolve) => setTimeout(resolve, ms)) } /** @@ -287,11 +287,7 @@ export const createCursor = ( await tracePath(path(previous, rand, options), true) previous = rand } - if (options?.moveDelay !== undefined && options.moveDelay >= 0) { - await delay(Math.random() * options.moveDelay) - } else { - await delay(Math.random() * 2000) // 2s by default - } + await delay(Math.random() * (options?.moveDelay ?? 2000)) randomMove().then( (_) => {}, (_) => {} @@ -326,11 +322,7 @@ export const createCursor = ( log('Warning: could not click mouse, error message:', error) } - if (options?.moveDelay !== undefined && options.moveDelay >= 0) { - await delay(Math.random() * options.moveDelay) - } else { - await delay(Math.random() * 2000) // 2s by default - } + await delay(Math.random() * (options?.moveDelay ?? 2000)) actions.toggleRandomMove(true) },