Skip to content

Commit d34d83e

Browse files
Merge pull request #23 from lightpanda-io/value.typeOf
Add Value.typeOf method
2 parents 62f9da3 + d01d248 commit d34d83e

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

src/binding.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,12 @@ const v8::Value* v8__Promise__Result(const v8::Promise& self) {
688688

689689
// Value
690690

691+
const v8::String* v8__Value__TypeOf(
692+
v8::Value& self,
693+
v8::Isolate* isolate) {
694+
return local_to_ptr(self.TypeOf(isolate));
695+
}
696+
691697
const v8::String* v8__Value__ToString(
692698
const v8::Value& self,
693699
const v8::Context& ctx) {

src/binding.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,9 @@ int v8__String__WriteUtf8(const String* str, Isolate* isolate, const char* buf,
371371
int v8__String__Utf8Length(const String* str, Isolate* isolate);
372372

373373
// Value
374+
String* v8__Value__TypeOf(
375+
const Value* self,
376+
Isolate* isolate);
374377
String* v8__Value__ToString(
375378
const Value* self,
376379
const Context* ctx);

src/v8.zig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1829,6 +1829,12 @@ pub const Value = struct {
18291829

18301830
handle: *const c.Value,
18311831

1832+
pub fn typeOf(self: Self, isolate: Isolate) !String {
1833+
return String{
1834+
.handle = c.v8__Value__TypeOf(self.handle, isolate.handle) orelse return error.JsException,
1835+
};
1836+
}
1837+
18321838
pub fn toString(self: Self, ctx: Context) !String {
18331839
return String{
18341840
.handle = c.v8__Value__ToString(self.handle, ctx.handle) orelse return error.JsException,

0 commit comments

Comments
 (0)