diff options
Diffstat (limited to 'src/javascript/jsc/node')
-rw-r--r-- | src/javascript/jsc/node/types.zig | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/javascript/jsc/node/types.zig b/src/javascript/jsc/node/types.zig index f3beeef8d..496e1c910 100644 --- a/src/javascript/jsc/node/types.zig +++ b/src/javascript/jsc/node/types.zig @@ -755,7 +755,15 @@ fn StatsLike(comptime name: [:0]const u8, comptime T: type) type { pub const Class = JSC.NewClass( This, .{ .name = name }, - .{}, + .{ + .isFile = .{ + .rfn = JSC.wrap(This, "isFile", false), + }, + .isDirectory = .{ + .rfn = JSC.wrap(This, "isDirectory", false), + }, + .finalize = finalize, + }, .{ .dev = .{ .get = JSC.To.JS.Getter(This, .dev), @@ -887,6 +895,13 @@ fn StatsLike(comptime name: [:0]const u8, comptime T: type) type { }; } + pub fn isFile(this: *Stats) JSC.JSValue { + return JSC.JSValue.jsBoolean(os.S.ISREG(@intCast(os.mode_t, this.mode))); + } + pub fn isDirectory(this: *Stats) JSC.JSValue { + return JSC.JSValue.jsBoolean(os.S.ISDIR(@intCast(os.mode_t, this.mode))); + } + pub fn toJS(this: Stats, ctx: JSC.C.JSContextRef, _: JSC.C.ExceptionRef) JSC.C.JSValueRef { var _this = bun.default_allocator.create(Stats) catch unreachable; _this.* = this; |