| 255 | |
| 256 | template <class V> |
| 257 | static 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 |
no test coverage detected