From cb2f68ebc326a3920d5081814e92fdc63c65c0d6 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Fri, 18 Apr 2025 19:13:27 -0400 Subject: [PATCH] QOL --- playgrounds/sandbox/index.html | 6 ++++++ playgrounds/sandbox/ssr-common.js | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/playgrounds/sandbox/index.html b/playgrounds/sandbox/index.html index 845538abf0..d70409ffb6 100644 --- a/playgrounds/sandbox/index.html +++ b/playgrounds/sandbox/index.html @@ -14,6 +14,12 @@ import { mount, hydrate, unmount } from 'svelte'; import App from '/src/App.svelte'; + globalThis.delayed = (v, ms = 1000) => { + return new Promise((f) => { + setTimeout(() => f(v), ms); + }); + }; + const root = document.getElementById('root'); const render = root.firstChild?.nextSibling ? hydrate : mount; diff --git a/playgrounds/sandbox/ssr-common.js b/playgrounds/sandbox/ssr-common.js index 60c6b52eb1..db3e085508 100644 --- a/playgrounds/sandbox/ssr-common.js +++ b/playgrounds/sandbox/ssr-common.js @@ -9,3 +9,9 @@ Promise.withResolvers ??= () => { return { promise, resolve, reject }; }; + +globalThis.delayed = (v, ms = 1000) => { + return new Promise((f) => { + setTimeout(() => f(v), ms); + }); +};