| 741 | } |
| 742 | |
| 743 | static napi_value encodeInt32(napi_env env, napi_callback_info info) { |
| 744 | size_t argc = 4; |
| 745 | napi_value args[4] = {nullptr}; |
| 746 | NAPI_CALL(napi_get_cb_info(env, info, &argc, args, nullptr, nullptr)); |
| 747 | |
| 748 | auto handle = NValueToUInt64(env, args[0]); |
| 749 | auto key = NValueToString(env, args[1]); |
| 750 | MMKV *kv = reinterpret_cast<MMKV *>(handle); |
| 751 | if (kv && key.length() > 0) { |
| 752 | auto value = NValueToInt32(env, args[2]); |
| 753 | if (IsNValueUndefined(env, args[3])) { |
| 754 | auto ret = kv->set(value, key); |
| 755 | return BoolToNValue(env, ret); |
| 756 | } |
| 757 | uint32_t expiration = NValueToUInt32(env, args[3]); |
| 758 | auto ret = kv->set(value, key, expiration); |
| 759 | return BoolToNValue(env, ret); |
| 760 | } |
| 761 | return BoolToNValue(env, false); |
| 762 | } |
| 763 | |
| 764 | static napi_value decodeInt32(napi_env env, napi_callback_info info) { |
| 765 | size_t argc = 3; |
nothing calls this directly
no test coverage detected