mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 02:48:50 +00:00
lil helper method
This commit is contained in:
@@ -1888,6 +1888,10 @@ pub const RefString = struct {
|
||||
pub const Hash = u32;
|
||||
pub const Map = std.HashMap(Hash, *JSC.RefString, IdentityContext(Hash), 80);
|
||||
|
||||
pub fn toJS(this: *RefString, global: *JSC.JSGlobalObject) JSValue {
|
||||
return JSC.ZigString.init(this.slice()).external(global, this, RefString__external);
|
||||
}
|
||||
|
||||
pub const Callback = fn (ctx: *anyopaque, str: *RefString) void;
|
||||
|
||||
pub fn computeHash(input: []const u8) u32 {
|
||||
@@ -1921,6 +1925,10 @@ pub const RefString = struct {
|
||||
this.deref();
|
||||
}
|
||||
|
||||
pub export fn RefString__external(this: ?*anyopaque, _: ?*anyopaque, _: usize) void {
|
||||
bun.cast(*RefString, this.?).deref();
|
||||
}
|
||||
|
||||
pub fn deinit(this: *RefString) void {
|
||||
if (this.onBeforeDeinit) |onBeforeDeinit| {
|
||||
onBeforeDeinit(this.ctx.?, this);
|
||||
|
||||
Reference in New Issue
Block a user