mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 23:23:28 +00:00
Add UndefinedOr(T) union
Some apis want a value or undefined. For these, we can't use an Optional return type, null maps to JS null. Adds an Env.UndefinedOr(T) generic union for such return types.
This commit is contained in:
@@ -1858,6 +1858,13 @@ pub fn Env(comptime State: type, comptime WebApis: type) type {
|
||||
}
|
||||
};
|
||||
|
||||
pub fn UndefinedOr(comptime T: type) type {
|
||||
return union(enum) {
|
||||
value: T,
|
||||
undefined: void,
|
||||
};
|
||||
}
|
||||
|
||||
fn compileModule(isolate: v8.Isolate, src: []const u8, name: []const u8) !v8.Module {
|
||||
// compile
|
||||
const script_name = v8.String.initUtf8(isolate, name);
|
||||
|
||||
Reference in New Issue
Block a user