diff --git a/packages/react-native/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleUtils.cpp b/packages/react-native/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleUtils.cpp index 2a7bbb51429..c3915063a6a 100644 --- a/packages/react-native/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleUtils.cpp +++ b/packages/react-native/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleUtils.cpp @@ -9,59 +9,6 @@ namespace facebook::react { -static jsi::Value deepCopyJSIValue(jsi::Runtime& rt, const jsi::Value& value) { - if (value.isNull()) { - return jsi::Value::null(); - } - - if (value.isBool()) { - return jsi::Value(value.getBool()); - } - - if (value.isNumber()) { - return jsi::Value(value.getNumber()); - } - - if (value.isString()) { - return value.getString(rt); - } - - if (value.isObject()) { - jsi::Object o = value.getObject(rt); - if (o.isArray(rt)) { - return deepCopyJSIArray(rt, o.getArray(rt)); - } - if (o.isFunction(rt)) { - return o.getFunction(rt); - } - return deepCopyJSIObject(rt, o); - } - - return jsi::Value::undefined(); -} - -jsi::Object deepCopyJSIObject(jsi::Runtime& rt, const jsi::Object& obj) { - jsi::Object copy(rt); - jsi::Array propertyNames = obj.getPropertyNames(rt); - size_t size = propertyNames.size(rt); - for (size_t i = 0; i < size; i++) { - jsi::String name = propertyNames.getValueAtIndex(rt, i).getString(rt); - jsi::Value value = obj.getProperty(rt, name); - copy.setProperty(rt, name, deepCopyJSIValue(rt, value)); - } - return copy; -} - -jsi::Array deepCopyJSIArray(jsi::Runtime& rt, const jsi::Array& arr) { - size_t size = arr.size(rt); - jsi::Array copy(rt, size); - for (size_t i = 0; i < size; i++) { - copy.setValueAtIndex( - rt, i, deepCopyJSIValue(rt, arr.getValueAtIndex(rt, i))); - } - return copy; -} - Promise::Promise(jsi::Runtime& rt, jsi::Function resolve, jsi::Function reject) : LongLivedObject(rt), resolve_(std::move(resolve)), diff --git a/packages/react-native/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleUtils.h b/packages/react-native/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleUtils.h index 005fc1504ef..704116f97eb 100644 --- a/packages/react-native/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleUtils.h +++ b/packages/react-native/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleUtils.h @@ -7,18 +7,14 @@ #pragma once +#include +#include #include +#include #include -#include -#include -#include - namespace facebook::react { -jsi::Object deepCopyJSIObject(jsi::Runtime& rt, const jsi::Object& obj); -jsi::Array deepCopyJSIArray(jsi::Runtime& rt, const jsi::Array& arr); - struct Promise : public LongLivedObject { Promise(jsi::Runtime& rt, jsi::Function resolve, jsi::Function reject);