MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / until

Function until

tooling/scripts/sidebar-vim-smoke.mjs:144–152  ·  view source on GitHub ↗

Poll an evaluated expression until it returns truthy (or time out → null).

(client, expression, timeoutMs = 4000, intervalMs = 80)

Source from the content-addressed store, hash-verified

142}
143/** Poll an evaluated expression until it returns truthy (or time out → null). */
144async function until(client, expression, timeoutMs = 4000, intervalMs = 80) {
145 const deadline = Date.now() + timeoutMs
146 while (Date.now() < deadline) {
147 const v = await evaluate(client, expression)
148 if (v) return v
149 await sleep(intervalMs)
150 }
151 return null
152}
153function pressKey(client, key, shift = false) {
154 const code = key.length === 1 ? `Key${key.toUpperCase()}` : key
155 return evaluate(client, `(() => { window.dispatchEvent(new KeyboardEvent('keydown', { key: ${JSON.stringify(key)}, code: ${JSON.stringify(code)}, shiftKey: ${shift}, bubbles: true, cancelable: true })); return true; })()`)

Callers 1

mainFunction · 0.85

Calls 2

evaluateFunction · 0.70
sleepFunction · 0.70

Tested by

no test coverage detected