aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/base.zig
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/bun.js/base.zig14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/bun.js/base.zig b/src/bun.js/base.zig
index 59cad571b..199a1c381 100644
--- a/src/bun.js/base.zig
+++ b/src/bun.js/base.zig
@@ -4017,6 +4017,20 @@ pub const Strong = struct {
return result;
}
+ pub fn has(this: *Strong) bool {
+ var ref = this.ref orelse return false;
+ return ref.get() != .zero;
+ }
+
+ pub fn trySwap(this: *Strong) ?JSValue {
+ const result = this.swap();
+ if (result == .zero) {
+ return null;
+ }
+
+ return result;
+ }
+
pub fn set(this: *Strong, globalThis: *JSC.JSGlobalObject, value: JSValue) void {
var ref: *JSC.napi.Ref = this.ref orelse {
if (value == .zero) return;