diff options
author | 2022-12-17 11:48:07 -0800 | |
---|---|---|
committer | 2022-12-17 12:26:19 -0800 | |
commit | e59c6f642dbbfe3dae0eb9a0d079a9a636d1394e (patch) | |
tree | 1d6820a5ccb477fc06d9ec0739adbb26b19a598b /src/bun.js | |
parent | 1bdb4b2466c277aeba0f8de81601d8a46be049d4 (diff) | |
download | bun-e59c6f642dbbfe3dae0eb9a0d079a9a636d1394e.tar.gz bun-e59c6f642dbbfe3dae0eb9a0d079a9a636d1394e.tar.zst bun-e59c6f642dbbfe3dae0eb9a0d079a9a636d1394e.zip |
Add `strict` option to Bun.deepEquals
Diffstat (limited to 'src/bun.js')
-rw-r--r-- | src/bun.js/bindings/ZigGlobalObject.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp index 06a4bbd87..1e70fdd99 100644 --- a/src/bun.js/bindings/ZigGlobalObject.cpp +++ b/src/bun.js/bindings/ZigGlobalObject.cpp @@ -1814,14 +1814,21 @@ JSC_DEFINE_HOST_FUNCTION(functionBunDeepEquals, (JSGlobalObject * globalObject, return JSValue::encode(jsUndefined()); } - JSC::JSValue arg1 = callFrame->argument(0); - JSC::JSValue arg2 = callFrame->argument(1); + JSC::JSValue arg1 = callFrame->uncheckedArgument(0); + JSC::JSValue arg2 = callFrame->uncheckedArgument(1); + JSC::JSValue arg3 = callFrame->argument(2); Vector<std::pair<JSValue, JSValue>, 16> stack; - bool isEqual = Bun__deepEquals<false>(globalObject, arg1, arg2, stack, &scope, true); - RETURN_IF_EXCEPTION(scope, {}); - return JSValue::encode(jsBoolean(isEqual)); + if (arg3.isBoolean() && arg3.asBoolean()) { + bool isEqual = Bun__deepEquals<true>(globalObject, arg1, arg2, stack, &scope, true); + RETURN_IF_EXCEPTION(scope, {}); + return JSValue::encode(jsBoolean(isEqual)); + } else { + bool isEqual = Bun__deepEquals<false>(globalObject, arg1, arg2, stack, &scope, true); + RETURN_IF_EXCEPTION(scope, {}); + return JSValue::encode(jsBoolean(isEqual)); + } } JSC_DECLARE_HOST_FUNCTION(functionBunNanoseconds); |