diff options
Diffstat (limited to 'src/js/builtins')
-rw-r--r-- | src/js/builtins/BunBuiltinNames.h | 1 | ||||
-rw-r--r-- | src/js/builtins/EventStream.ts | 7 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/js/builtins/BunBuiltinNames.h b/src/js/builtins/BunBuiltinNames.h index 1897f939e..776f39fec 100644 --- a/src/js/builtins/BunBuiltinNames.h +++ b/src/js/builtins/BunBuiltinNames.h @@ -71,6 +71,7 @@ using namespace JSC; macro(consumeReadableStream) \ macro(controlledReadableStream) \ macro(controller) \ + macro(contentType) \ macro(cork) \ macro(createCommonJSModule) \ macro(createEmptyReadableStream) \ diff --git a/src/js/builtins/EventStream.ts b/src/js/builtins/EventStream.ts index c2ce30f17..c9d574836 100644 --- a/src/js/builtins/EventStream.ts +++ b/src/js/builtins/EventStream.ts @@ -16,12 +16,13 @@ export function getEventStream() { this.#ctrl = undefined; }, }); + $putByIdDirectPrivate(this, "contentType", "text/event-stream"); } send(event?: unknown, data?: unknown): void { var ctrl = this.#ctrl!; if (!ctrl) { - throw new Error("EventStream has ended"); + throw new Error("EventStream is closed"); } if (!data) { data = event; @@ -42,5 +43,9 @@ export function getEventStream() { } ctrl.flush(); } + + close() { + this.#ctrl?.close(); + } }; } |