diff options
Diffstat (limited to 'src/bun.js/api/bun.zig')
-rw-r--r-- | src/bun.js/api/bun.zig | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/bun.js/api/bun.zig b/src/bun.js/api/bun.zig index 2e6381c74..9932d10cc 100644 --- a/src/bun.js/api/bun.zig +++ b/src/bun.js/api/bun.zig @@ -1364,6 +1364,9 @@ pub const Class = NewClass( .FileSystemRouter = .{ .get = getFileSystemRouter, }, + .EventStream = .{ + .get = getEventStream, + }, }, ); @@ -3382,6 +3385,26 @@ pub fn getUnsafe( return existing.asObjectRef(); } +extern fn ZigGlobalObject__createEventStream(*JSGlobalObject) JSValue; + +pub fn getEventStream( + _: void, + ctx: js.JSContextRef, + _: js.JSValueRef, + _: js.JSStringRef, + _: js.ExceptionRef, +) js.JSValueRef { + var existing = ctx.ptr().getCachedObject(ZigString.static("EventStream")); + if (existing.isEmpty()) { + return ctx.ptr().putCachedObject( + &ZigString.init("EventStream"), + ZigGlobalObject__createEventStream(ctx.ptr()), + ).asObjectRef(); + } + + return existing.asObjectRef(); +} + pub const Unsafe = struct { pub const Class = NewClass( void, |