diff options
author | 2023-02-28 00:02:44 -0800 | |
---|---|---|
committer | 2023-02-28 00:12:32 -0800 | |
commit | 12d6db0cad2554562f3f5034c3bc5c448702a270 (patch) | |
tree | 4dfac5705969ea2b3a31e5d2f3a1f2800808c470 /src | |
parent | ec7929b251b91745f676ce85f173516186f36c6e (diff) | |
download | bun-12d6db0cad2554562f3f5034c3bc5c448702a270.tar.gz bun-12d6db0cad2554562f3f5034c3bc5c448702a270.tar.zst bun-12d6db0cad2554562f3f5034c3bc5c448702a270.zip |
Add explicit Null tag to Body
This reverts commit e538bb31ad7a2c4b4ce2b1f7d6b18a3140939950.
Diffstat (limited to 'src')
-rw-r--r-- | src/bun.js/webcore/body.zig | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/bun.js/webcore/body.zig b/src/bun.js/webcore/body.zig index f76587f74..97c9f7874 100644 --- a/src/bun.js/webcore/body.zig +++ b/src/bun.js/webcore/body.zig @@ -294,6 +294,7 @@ pub const Body = struct { Used: void, Empty: void, Error: JSValue, + Null: void, pub fn toBlobIfPossible(this: *Value) void { if (this.* != .Locked) @@ -355,6 +356,7 @@ pub const Body = struct { Used, Empty, Error, + Null, }; // pub const empty = Value{ .Empty = void{} }; @@ -363,12 +365,12 @@ pub const Body = struct { JSC.markBinding(@src()); switch (this.*) { - .Empty => { - return JSValue.jsNull(); - }, - .Used => { + .Used, .Empty => { return JSC.WebCore.ReadableStream.empty(globalThis); }, + .Null => { + return JSValue.null; + }, .InternalBlob, .Blob, // .InlineBlob, @@ -436,12 +438,15 @@ pub const Body = struct { } } - pub fn fromJS(globalThis: *JSGlobalObject, value: JSValue) ?Value { + pub fn fromJS( + globalThis: *JSGlobalObject, + value: JSValue, + ) ?Value { value.ensureStillAlive(); if (value.isEmptyOrUndefinedOrNull()) { return Body.Value{ - .Empty = void{}, + .Null = void{}, }; } @@ -976,10 +981,6 @@ pub fn BodyMixin(comptime Type: type) type { ) callconv(.C) JSValue { var body: *Body.Value = this.getBodyValue(); - if (body.* == .Empty) { - return JSValue.jsNull(); - } - if (body.* == .Used) { // TODO: make this closed return JSC.WebCore.ReadableStream.empty(globalThis); @@ -1001,7 +1002,6 @@ pub fn BodyMixin(comptime Type: type) type { _: *JSC.CallFrame, ) callconv(.C) JSC.JSValue { var value: *Body.Value = this.getBodyValue(); - if (value.* == .Used) { return handleBodyAlreadyUsed(globalObject); } |