template<typename T>
static T* fromjs(const Local<Value> &m) {
Nan::HandleScope scope;
if(!m->IsObject()) { Nan::ThrowError(Nan::Error("Only objects accepted in metadata APIs")); return nullptr; }
MaybeLocal<Value> ptr = Nan::Get(Nan::To<Object>(m).ToLocalChecked(), Nan::New("_ptr").ToLocalChecked());
if(ptr.IsEmpty()) { Nan::ThrowError(Nan::Error("This object was not created by the FLAC API")); return nullptr; }
if(!m->IsObject()) { Nan::ThrowError(Nan::Error("This object was not created by the API or was modified incorrecty")); return nullptr; }
Local<Value> ptr2 = ptr.ToLocalChecked();
if(!Buffer::HasInstance(ptr2)) { Nan::ThrowError(Nan::Error("This object was modified incorrectly")); return nullptr; }
return UnwrapPointer<T>(ptr2);
}
There is a double check of !m->IsObject(), does is should be ptr.IsObject()
There is a double check of
!m->IsObject()
, does is should beptr.IsObject()