From 0802633e7b97e5ce38c1f37b5a1669501cde0484 Mon Sep 17 00:00:00 2001 From: Aris Kemper Date: Tue, 23 Jan 2024 09:12:02 +0100 Subject: [PATCH] refactor(utils/stream): stream pull (#2057) --- deno_dist/utils/stream.ts | 6 +----- src/utils/stream.ts | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/deno_dist/utils/stream.ts b/deno_dist/utils/stream.ts index a2978a403..7dfd4e4e5 100644 --- a/deno_dist/utils/stream.ts +++ b/deno_dist/utils/stream.ts @@ -15,11 +15,7 @@ export class StreamingApi { this.responseReadable = new ReadableStream({ async pull(controller) { const { done, value } = await reader.read() - if (done) { - controller.close() - } else { - controller.enqueue(value) - } + done ? controller.close() : controller.enqueue(value) }, cancel: () => { this.abortSubscribers.forEach((subscriber) => subscriber()) diff --git a/src/utils/stream.ts b/src/utils/stream.ts index a2978a403..7dfd4e4e5 100644 --- a/src/utils/stream.ts +++ b/src/utils/stream.ts @@ -15,11 +15,7 @@ export class StreamingApi { this.responseReadable = new ReadableStream({ async pull(controller) { const { done, value } = await reader.read() - if (done) { - controller.close() - } else { - controller.enqueue(value) - } + done ? controller.close() : controller.enqueue(value) }, cancel: () => { this.abortSubscribers.forEach((subscriber) => subscriber())