aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Dylan Conway <dylan.conway567@gmail.com> 2023-02-21 12:18:24 -0800
committerGravatar Dylan Conway <dylan.conway567@gmail.com> 2023-02-21 12:18:24 -0800
commit88c238dc5c125228f11940cbb65b7ae7b6aac6df (patch)
tree3e5ab70d1d72839e8a108c81f5e79a99ab6e5ab5
parent12b2ad736321d0e501b841a02194062c6a0f07bd (diff)
downloadbun-88c238dc5c125228f11940cbb65b7ae7b6aac6df.tar.gz
bun-88c238dc5c125228f11940cbb65b7ae7b6aac6df.tar.zst
bun-88c238dc5c125228f11940cbb65b7ae7b6aac6df.zip
`isRegExp()` without cpp
-rw-r--r--src/bun.js/bindings/bindings.zig8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/bun.js/bindings/bindings.zig b/src/bun.js/bindings/bindings.zig
index 800fd0af9..a98d350c2 100644
--- a/src/bun.js/bindings/bindings.zig
+++ b/src/bun.js/bindings/bindings.zig
@@ -3055,6 +3055,10 @@ pub const JSValue = enum(JSValueReprInt) {
return JSBuffer__isBuffer(global, value);
}
+ pub fn isRegExp(this: JSValue) bool {
+ return this.jsType() == .RegExpObject;
+ }
+
pub fn asCheckLoaded(value: JSValue, comptime ZigType: type) ?*ZigType {
if (!ZigType.Class.isLoaded() or value.isUndefinedOrNull())
return null;
@@ -3655,8 +3659,10 @@ pub const JSValue = enum(JSValueReprInt) {
};
pub fn determineDiffMethod(this: JSValue, other: JSValue, global: *JSGlobalObject) DiffMethod {
- if ((this.isString() and other.isString()) or (this.jsType() == .RegExpObject and other.jsType() == .RegExpObject) or (this.isBuffer(global) and other.isBuffer(global))) return .character;
+ if ((this.isString() and other.isString()) or (this.isBuffer(global) and other.isBuffer(global))) return .character;
+ if ((this.isRegExp() and other.isObject()) or (this.isObject() and other.isRegExp())) return .character;
if (this.isObject() and other.isObject()) return .line;
+
return .none;
}