UNPKG

1.03 kBtext/x-cView Raw
1/*********************************************************************
2 * NAN - Native Abstractions for Node.js
3 *
4 * Copyright (c) 2018 NAN contributors
5 *
6 * MIT License <https://github.com/nodejs/nan/blob/master/LICENSE.md>
7 ********************************************************************/
8
9#ifndef NAN_DEFINE_OWN_PROPERTY_HELPER_H_
10#define NAN_DEFINE_OWN_PROPERTY_HELPER_H_
11
12namespace imp {
13
14inline 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))
24 : Nothing<bool>();
25}
26
27} // end of namespace imp
28
29#endif // NAN_DEFINE_OWN_PROPERTY_HELPER_H_