diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/javascript/jsc/api/bun.zig | 34 | ||||
-rw-r--r-- | src/javascript/jsc/node/node_fs.zig | 2 |
2 files changed, 35 insertions, 1 deletions
diff --git a/src/javascript/jsc/api/bun.zig b/src/javascript/jsc/api/bun.zig index 814fd361c..64cc72ecc 100644 --- a/src/javascript/jsc/api/bun.zig +++ b/src/javascript/jsc/api/bun.zig @@ -938,6 +938,10 @@ pub const Class = NewClass( .rfn = Bun.runGC, .ts = d.ts{}, }, + .allocUnsafe = .{ + .rfn = Bun.allocUnsafe, + .ts = .{}, + }, .generateHeapSnapshot = .{ .rfn = Bun.generateHeapSnapshot, .ts = d.ts{}, @@ -979,6 +983,7 @@ pub const Class = NewClass( .env = .{ .get = EnvironmentVariables.getter, }, + .enableANSIColors = .{ .get = enableANSIColors, }, @@ -996,6 +1001,35 @@ pub const Class = NewClass( }, ); +pub fn allocUnsafe( + _: void, + ctx: js.JSContextRef, + _: js.JSObjectRef, + _: js.JSObjectRef, + arguments: []const js.JSValueRef, + exception: js.ExceptionRef, +) js.JSValueRef { + var args = JSC.Node.ArgumentsSlice.from(arguments); + + const length = @intCast( + usize, + @minimum( + @maximum(1, (args.nextEat() orelse JSC.JSValue.jsNumber(@as(i32, 1))).toInt32()), + std.math.maxInt(i32), + ), + ); + var bytes = bun.default_allocator.alloc(u8, length) catch { + JSC.JSError(bun.default_allocator, "OOM! Out of memory", .{}, ctx, exception); + return null; + }; + + return JSC.MarkedArrayBuffer.fromBytes( + bytes, + bun.default_allocator, + .Uint8Array, + ).toJSObjectRef(ctx, null); +} + pub fn getTranspilerConstructor( _: void, ctx: js.JSContextRef, diff --git a/src/javascript/jsc/node/node_fs.zig b/src/javascript/jsc/node/node_fs.zig index b7aacbf97..0c47d3aa9 100644 --- a/src/javascript/jsc/node/node_fs.zig +++ b/src/javascript/jsc/node/node_fs.zig @@ -2168,7 +2168,7 @@ const Arguments = struct { }; }; -const Constants = struct { +pub const Constants = struct { // File Access Constants /// Constant for fs.access(). File is visible to the calling process. pub const F_OK = std.os.F_OK; |