1 /*********************************************************************
2 * NAN - Native Abstractions for Node.js
4 * Copyright (c) 2018 NAN contributors
6 * MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
7 ********************************************************************/
9 #ifndef NAN_DEFINE_OWN_PROPERTY_HELPER_H_
10 #define NAN_DEFINE_OWN_PROPERTY_HELPER_H_
14 inline Maybe<bool> DefineOwnPropertyHelper(
15 v8::PropertyAttribute current
16 , v8::Handle<v8::Object> obj
17 , v8::Handle<v8::String> key
18 , v8::Handle<v8::Value> value
19 , v8::PropertyAttribute attribs = v8::None) {
20 return !(current & v8::DontDelete) || // configurable OR
21 (!(current & v8::ReadOnly) && // writable AND
22 !((attribs ^ current) & ~v8::ReadOnly)) // same excluding RO
23 ? Just<bool>(obj->ForceSet(key, value, attribs))
27 } // end of namespace imp
29 #endif // NAN_DEFINE_OWN_PROPERTY_HELPER_H_