MCPcopy Create free account
hub / github.com/Tencent/MMKV / NValueToStringArray

Function NValueToStringArray

OpenHarmony/MMKV/src/main/cpp/native_bridge.cpp:79–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

77}
78
79static vector<string> NValueToStringArray(napi_env env, napi_value value, bool maybeUndefined = false) {
80 vector<string> keys;
81 if (maybeUndefined && IsNValueUndefined(env, value)) {
82 return keys;
83 }
84
85 uint32_t length = 0;
86 if (napi_get_array_length(env, value, &length) != napi_ok || length == 0) {
87 return keys;
88 }
89 keys.reserve(length);
90
91 for (uint32_t index = 0; index < length; index++) {
92 napi_value jsKey = nullptr;
93 if (napi_get_element(env, value, index, &jsKey) != napi_ok) {
94 continue;
95 }
96 keys.push_back(NValueToString(env, jsKey));
97 }
98 return keys;
99}
100
101static napi_value StringArrayToNValue(napi_env env, const vector<string> &value) {
102 napi_value jsArr = nullptr;

Callers 2

encodeStringSetFunction · 0.85
removeValuesForKeysFunction · 0.85

Calls 2

IsNValueUndefinedFunction · 0.70
NValueToStringFunction · 0.70

Tested by

no test coverage detected