Stream: put all phases in switch-case

This commit is contained in:
Andre Staltz 2023-04-12 22:34:32 +03:00
parent 9f25aeeffa
commit f3a8d805e9
1 changed files with 4 additions and 1 deletions

View File

@ -248,7 +248,7 @@ class SyncStream extends Pipeable {
for (const id of this.#requested) {
if (!this.#canSend()) return
this.#sendLocalHave(id)
this.write({ id, phase: 0 })
}
}
@ -257,6 +257,9 @@ class SyncStream extends Pipeable {
const { id, phase, payload } = data
switch (phase) {
case 0: {
return this.#sendLocalHave(id)
}
case 1: {
return this.#sendLocalHaveAndWant(id, payload)
}