#pragma once #include "./NanStrings.h" #include #include namespace Nan { inline v8::MaybeLocal GetObject(v8::Local object, v8::Local key) { auto result = Nan::Get(object, key); if(result.IsEmpty()) return v8::Local{}; return result.ToLocalChecked()->ToObject(v8::Isolate::GetCurrent()->GetCurrentContext()); } inline v8::MaybeLocal Get(v8::Local object, const std::string_view& key) { return Nan::Get(object, Nan::LocalString(key)); } template ::value, int>::type * = nullptr> inline v8::MaybeLocal Get(v8::Local object, K key) { MaybeLocal result{Nan::Get(object, key)}; if(result.IsEmpty()) return v8::Local{}; return result.ToLocalChecked().As(); } template inline v8::Local GetLocal(v8::Local object, K key) { return Nan::Get(object, key).FromMaybe(v8::Local{}); } template inline v8::MaybeLocal GetString(v8::Local object, T key) { return Get(object, key); } template inline v8::Local GetStringLocal(v8::Local object, T key) { return GetLocal(object, key); } }