// Creating a self-destruct sequence (that we can cancel!)const controller = new AbortController();async function selfDestruct() { try { for(let i = 10; i > 0; i--) { controller.signal.throwIfAborted(); print(`Self-destruct in ${i}...`); await sleep(1000); } print("💥 BOOM!"); } catch (e) { print("Self-destruct cancelled! Phew!"); }}// Start the countdownselfDestruct();// Changed our mind? Just abort!controller.abort("Never mind!"); Copy
// Creating a self-destruct sequence (that we can cancel!)const controller = new AbortController();async function selfDestruct() { try { for(let i = 10; i > 0; i--) { controller.signal.throwIfAborted(); print(`Self-destruct in ${i}...`); await sleep(1000); } print("💥 BOOM!"); } catch (e) { print("Self-destruct cancelled! Phew!"); }}// Start the countdownselfDestruct();// Changed our mind? Just abort!controller.abort("Never mind!");
Common Use Cases:
This implementation closely follows the web standard but is adapted for ComputerCraft's environment. Some subtle differences may exist.
Example
Common Use Cases:
Warning
This implementation closely follows the web standard but is adapted for ComputerCraft's environment. Some subtle differences may exist.