MCPcopy Create free account
hub / github.com/NodeRT/NodeRT / FillMapFromJsObject

Function FillMapFromJsObject

src/NodeRTLib/ProjectFiles/CollectionsConverter.h:257–279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

255
256template <class V>
257static bool FillMapFromJsObject(
258 v8::Local<v8::Object> obj,
259 const std::function<bool(v8::Local<v8::Value>)>& checkKeyTypeFunc,
260 const std::function<::Platform::String ^ (v8::Local<v8::Value>)>&
261 convertToKeyTypeFunc,
262 const std::function<bool(v8::Local<v8::Value>)>& checkValueTypeFunc,
263 const std::function<V(v8::Local<v8::Value>)>& convertToValueTypeFunc,
264 std::map<::Platform::String ^, V>& stdMap) {
265 Local<Array> objProps = Nan::GetPropertyNames(obj).ToLocalChecked();
266 for (uint32_t i = 0; i < objProps->Length(); i++) {
267 Local<Value> key = Nan::Get(objProps, i).ToLocalChecked();
268 Local<Value> value = Nan::Get(obj, key).ToLocalChecked();
269 if (!checkValueTypeFunc(value)) {
270 Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(
271 L"Received object with unexpected value type")));
272 return false;
273 }
274
275 stdMap.insert(std::pair<::Platform::String ^, V>(
276 convertToKeyTypeFunc(key), convertToValueTypeFunc(value)));
277 }
278 return true;
279}
280}; // namespace NodeRT

Callers 2

JsObjectToWinrtMapFunction · 0.85
JsObjectToWinrtMapViewFunction · 0.85

Calls 1

NewStringFunction · 0.85

Tested by

no test coverage detected