|
4 | 4 | namespace node {
|
5 | 5 | namespace util {
|
6 | 6 |
|
| 7 | +using v8::ALL_PROPERTIES; |
7 | 8 | using v8::Array;
|
8 | 9 | using v8::Context;
|
9 | 10 | using v8::FunctionCallbackInfo;
|
10 | 11 | using v8::Integer;
|
11 | 12 | using v8::Local;
|
12 | 13 | using v8::Object;
|
| 14 | +using v8::ONLY_CONFIGURABLE; |
| 15 | +using v8::ONLY_ENUMERABLE; |
| 16 | +using v8::ONLY_WRITABLE; |
13 | 17 | using v8::Private;
|
14 | 18 | using v8::Promise;
|
15 | 19 | using v8::Proxy;
|
| 20 | +using v8::SKIP_STRINGS; |
| 21 | +using v8::SKIP_SYMBOLS; |
16 | 22 | using v8::String;
|
| 23 | +using v8::Uint32; |
17 | 24 | using v8::Value;
|
18 | 25 |
|
19 | 26 | static void GetOwnNonIndexProperties(
|
20 | 27 | const FunctionCallbackInfo<Value>& args) {
|
21 | 28 | Environment* env = Environment::GetCurrent(args);
|
22 | 29 | Local<Context> context = env->context();
|
23 | 30 |
|
24 |
| - if (!args[0]->IsObject()) |
25 |
| - return; |
| 31 | + CHECK(args[0]->IsObject()); |
| 32 | + CHECK(args[1]->IsUint32()); |
| 33 | + |
| 34 | + Local<Object> object = args[0].As<Object>(); |
26 | 35 |
|
27 |
| - v8::Local<v8::Object> object = args[0].As<v8::Object>(); |
| 36 | + Local<Array> properties; |
28 | 37 |
|
29 |
| - // Return only non-enumerable properties by default. |
30 |
| - v8::Local<v8::Array> properties; |
| 38 | + v8::PropertyFilter filter = |
| 39 | + static_cast<v8::PropertyFilter>(args[1].As<Uint32>()->Value()); |
31 | 40 |
|
32 | 41 | if (!object->GetPropertyNames(
|
33 | 42 | context, v8::KeyCollectionMode::kOwnOnly,
|
34 |
| - v8::ONLY_ENUMERABLE, |
| 43 | + filter, |
35 | 44 | v8::IndexFilter::kSkipIndices)
|
36 | 45 | .ToLocal(&properties)) {
|
37 | 46 | return;
|
@@ -209,6 +218,17 @@ void Initialize(Local<Object> target,
|
209 | 218 | WatchdogHasPendingSigint);
|
210 | 219 |
|
211 | 220 | env->SetMethod(target, "safeGetenv", SafeGetenv);
|
| 221 | + |
| 222 | + Local<Object> constants = Object::New(env->isolate()); |
| 223 | + NODE_DEFINE_CONSTANT(constants, ALL_PROPERTIES); |
| 224 | + NODE_DEFINE_CONSTANT(constants, ONLY_WRITABLE); |
| 225 | + NODE_DEFINE_CONSTANT(constants, ONLY_ENUMERABLE); |
| 226 | + NODE_DEFINE_CONSTANT(constants, ONLY_CONFIGURABLE); |
| 227 | + NODE_DEFINE_CONSTANT(constants, SKIP_STRINGS); |
| 228 | + NODE_DEFINE_CONSTANT(constants, SKIP_SYMBOLS); |
| 229 | + target->Set(context, |
| 230 | + FIXED_ONE_BYTE_STRING(env->isolate(), "propertyFilter"), |
| 231 | + constants).FromJust(); |
212 | 232 | }
|
213 | 233 |
|
214 | 234 | } // namespace util
|
|
0 commit comments