diff options
author | 2023-04-17 05:47:20 -0700 | |
---|---|---|
committer | 2023-04-17 05:47:20 -0700 | |
commit | fc539c278e59377c7992cdd0e806a709116209e1 (patch) | |
tree | 9766c82de6203fb705011bdde2593db181a7f780 | |
parent | d19005aa762b55114d26dabe4931a8c8aa3bfaae (diff) | |
download | bun-fc539c278e59377c7992cdd0e806a709116209e1.tar.gz bun-fc539c278e59377c7992cdd0e806a709116209e1.tar.zst bun-fc539c278e59377c7992cdd0e806a709116209e1.zip |
cleanup
-rw-r--r-- | src/bun.js/bindings/bindings.zig | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/bun.js/bindings/bindings.zig b/src/bun.js/bindings/bindings.zig index 20ca7738a..4ccacad7b 100644 --- a/src/bun.js/bindings/bindings.zig +++ b/src/bun.js/bindings/bindings.zig @@ -3976,10 +3976,10 @@ pub const JSValue = enum(JSValueReprInt) { return @field(Enum, map_name).getWithEql(target_str, ZigString.eqlComptime) orelse { const one_of = struct { pub const list = brk: { - var str = "'"; + var str: []const u8 = "'"; const field_names = std.meta.fieldNames(Enum); for (field_names, 0..) |entry, i| { - str = str ++ entry.key ++ "'"; + str = str ++ entry ++ "'"; if (i < field_names.len - 2) { str = str ++ ", '"; } else if (i == field_names.len - 2) { @@ -4009,8 +4009,10 @@ pub const JSValue = enum(JSValueReprInt) { pub fn getOptionalEnum(this: JSValue, globalThis: *JSGlobalObject, comptime property_name: []const u8, comptime Enum: type) !?Enum { if (get(this, globalThis, property_name)) |prop| { - return toEnum(prop, globalThis, property_name, Enum); + return try toEnum(prop, globalThis, property_name, Enum); } + + return null; } pub fn getArray(this: JSValue, globalThis: *JSGlobalObject, comptime property_name: []const u8) !?JSValue { @@ -4065,7 +4067,7 @@ pub const JSValue = enum(JSValueReprInt) { } if (prop.isNumber()) { - return prop.toNumber() != 0; + return prop.asDouble() != 0; } globalThis.throwInvalidArguments(property_name ++ " must be a boolean", .{}); @@ -4081,6 +4083,7 @@ pub const JSValue = enum(JSValueReprInt) { globalThis.throwInvalidArguments(property_name ++ " must be a string", .{}); return error.JSError; }, + else => @compileError("TODO:" ++ @typeName(T)), } } |