From 2c4033831ff1aee7f1d7268367f2a09b5b5a78ec Mon Sep 17 00:00:00 2001 From: ed Date: Sun, 2 Aug 2026 23:02:44 +0000 Subject: [PATCH] js: while(apop) --- copyparty/web/up2k.js | 1 + copyparty/web/util.js | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/copyparty/web/up2k.js b/copyparty/web/up2k.js index 6a7b0441..4ee0883a 100644 --- a/copyparty/web/up2k.js +++ b/copyparty/web/up2k.js @@ -2512,6 +2512,7 @@ function up2k_init(subtle) { keepalive = t.keepalive, me = Date.now(); + while (apop(st.todo.handshake, t)); if (t.done) return console.log('done; skip hs', t.name, t); diff --git a/copyparty/web/util.js b/copyparty/web/util.js index 92e1155a..5b2fad43 100644 --- a/copyparty/web/util.js +++ b/copyparty/web/util.js @@ -1199,8 +1199,10 @@ function has(haystack, needle) { function apop(arr, v) { var ofs = arr.indexOf(v); - if (ofs !== -1) + if (ofs !== -1) { arr.splice(ofs, 1); + return true; + } } @@ -1466,7 +1468,7 @@ function Debounce(delay) { }; r.rm = function (fun) { - apop(r.q, fun); + while (apop(r.q, fun)); }; r.run = function () { @@ -1526,7 +1528,7 @@ var timer = (function () { }; r.rm = function (fun) { - apop(r.q, fun); + while (apop(r.q, fun)); }; var doevents = function () {