Skip to content

Commit d0e09b1

Browse files
committed
Use Set to change elements in a Napi::Array
1 parent 32f5c22 commit d0e09b1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/main.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -126,18 +126,18 @@ Napi::Array EnumerateValues(Napi::Env& env, HKEY hCurrentKey) {
126126
{
127127
auto text = reinterpret_cast<LPWSTR>(buffer.get());
128128
auto obj = CreateEntry(env, achValue, L"REG_SZ", text, cbData);
129-
results[i] = obj;
129+
results.Set(i, obj);
130130
}
131131
else if (lpType == REG_EXPAND_SZ)
132132
{
133133
auto text = reinterpret_cast<LPWSTR>(buffer.get());
134134
auto obj = CreateEntry(env, achValue, L"REG_EXPAND_SZ", text, cbData);
135-
results[i] = obj;
135+
results.Set(i, obj);
136136
}
137137
else if (lpType == REG_DWORD)
138138
{
139139
assert(cbData == sizeof(DWORD));
140-
results[i] = CreateEntry(env, achValue, L"REG_DWORD", *reinterpret_cast<DWORD*>(buffer.get()));
140+
results.Set(i, CreateEntry(env, achValue, L"REG_DWORD", *reinterpret_cast<DWORD*>(buffer.get())));
141141
}
142142
}
143143
else if (retCode == ERROR_NO_MORE_ITEMS)
@@ -273,7 +273,7 @@ Napi::Value EnumKeys(const Napi::CallbackInfo& info) {
273273
auto ret = RegEnumKeyEx(hCurrentKey, i, name, &nameLen, nullptr, nullptr, nullptr, nullptr);
274274
if (ret == ERROR_SUCCESS)
275275
{
276-
results[i] = Napi::String::New(env, (char16_t*)name);
276+
results.Set(i, Napi::String::New(env, (char16_t*)name));
277277
continue;
278278
}
279279
break; // FIXME: We should do better error handling here

0 commit comments

Comments
 (0)