Skip to content

Commit 8ce13e3

Browse files
authored
Merge pull request #83 from lightpanda-io/is-promise
IsPromise
2 parents dd08777 + 7da2259 commit 8ce13e3

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

src/binding.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,8 @@ bool v8__Value__IsFunction(const v8::Value& self) { return self.IsFunction(); }
878878

879879
bool v8__Value__IsAsyncFunction(const v8::Value& self) { return self.IsAsyncFunction(); }
880880

881+
bool v8__Value__IsPromise(const v8::Value& self) { return self.IsPromise(); }
882+
881883
bool v8__Value__IsBoolean(const v8::Value& self) { return self.IsBoolean(); }
882884

883885
bool v8__Value__IsBooleanObject(const v8::Value& self) { return self.IsBooleanObject(); }

src/binding.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ void v8__Value__NumberValue(
477477
MaybeF64* out);
478478
bool v8__Value__IsFunction(const Value* self);
479479
bool v8__Value__IsAsyncFunction(const Value* self);
480+
bool v8__Value__IsPromise(const Value* self);
480481
bool v8__Value__IsBoolean(const Value* self);
481482
bool v8__Value__IsBooleanObject(const Value* self);
482483
bool v8__Value__IsInt32(const Value* self);

src/v8.zig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,13 @@ pub fn Persistent(comptime T: type) type {
949949
};
950950
}
951951

952+
/// Should only be called if you know the underlying type is a v8.Module.
953+
pub fn castToModule(self: Self) Module {
954+
return .{
955+
.handle = @as(*const c.Module, @ptrCast(self.handle)),
956+
};
957+
}
958+
952959
/// Should only be called if you know the underlying type is a v8.PromiseResolver.
953960
pub fn castToPromiseResolver(self: Self) PromiseResolver {
954961
return .{
@@ -2126,6 +2133,10 @@ pub const Value = struct {
21262133
return c.v8__Value__IsAsyncFunction(self.handle);
21272134
}
21282135

2136+
pub fn isPromise(self: Self) bool {
2137+
return c.v8__Value__IsPromise(self.handle);
2138+
}
2139+
21292140
pub fn isArray(self: Self) bool {
21302141
return c.v8__Value__IsArray(self.handle);
21312142
}

0 commit comments

Comments
 (0)