| 1156 | } |
| 1157 | |
| 1158 | static napi_value decodeBytes(napi_env env, napi_callback_info info) { |
| 1159 | size_t argc = 3; |
| 1160 | napi_value args[3] = {nullptr}; |
| 1161 | NAPI_CALL(napi_get_cb_info(env, info, &argc, args, nullptr, nullptr)); |
| 1162 | |
| 1163 | auto handle = NValueToUInt64(env, args[0]); |
| 1164 | auto key = NValueToString(env, args[1]); |
| 1165 | MMKV *kv = reinterpret_cast<MMKV *>(handle); |
| 1166 | if (kv && key.length() > 0) { |
| 1167 | MMBuffer result; |
| 1168 | if (kv->getBytes(key, result)) { |
| 1169 | return MMBufferToNValue(env, std::move(result)); |
| 1170 | } |
| 1171 | } |
| 1172 | return args[2]; |
| 1173 | } |
| 1174 | |
| 1175 | template <typename T> |
| 1176 | napi_value encodeArray(napi_env env, napi_callback_info info) { |
nothing calls this directly
no test coverage detected