Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ext/web): add AbortSignal.any() #21087

Merged
merged 14 commits into from
Nov 13, 2023
Prev Previous commit
Next Next commit
tweak
  • Loading branch information
petamoriken committed Nov 4, 2023
commit 3ad837dcc74756f455f94747360088ae11221222
14 changes: 7 additions & 7 deletions ext/web/03_abort_signal.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,29 +37,29 @@ import { refTimer, setTimeout, unrefTimer } from "ext:deno_web/02_timers.js";
// toArray method.
class WeakRefSet {
#weakSet = new SafeWeakSet();
#refSet = new SafeSet();
#refs = [];

add(value) {
if (WeakSetPrototypeHas(this.#weakSet, value)) {
return;
}
WeakSetPrototypeAdd(this.#weakSet, value);
SetPrototypeAdd(this.#refSet, new SafeWeakRef(value));
ArrayPrototypePush(this.#refs, new SafeWeakRef(value));
}

has(value) {
return WeakSetPrototypeHas(this.#weakSet, value);
}

toArray() {
const arr = [];
for (const ref of new SafeSetIterator(this.#refSet)) {
const value = WeakRefPrototypeDeref(ref);
const ret = [];
for (let i = 0; i < this.#refs.length; ++i) {
const value = WeakRefPrototypeDeref(this.#refs[i]);
if (value !== undefined) {
ArrayPrototypePush(arr, value);
ArrayPrototypePush(ret, value);
}
}
return arr;
return ret;
}
}

Expand Down
Loading