summaryrefslogtreecommitdiff
path: root/src/node_util.cc
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2018-08-20 03:26:27 +0200
committerRuben Bridgewater <ruben@bridgewater.de>2018-08-23 00:10:52 +0200
commit68b07ded9ceb23cf411fa4843b01f533efb600b4 (patch)
tree48bc30d2824d450540695bd4bb8e48370a2233dd /src/node_util.cc
parentc35ce5635cc368a5cadca0dd38098117c45679c9 (diff)
downloadandroid-node-v8-68b07ded9ceb23cf411fa4843b01f533efb600b4.tar.gz
android-node-v8-68b07ded9ceb23cf411fa4843b01f533efb600b4.tar.bz2
android-node-v8-68b07ded9ceb23cf411fa4843b01f533efb600b4.zip
repl: tab auto complete big arrays
Due to a new API it's possible to skip the indices. That allows to use auto completion with big (typed) arrays. PR-URL: https://github.com/nodejs/node/pull/22408 Fixes: https://github.com/nodejs/node/issues/21446 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'src/node_util.cc')
-rw-r--r--src/node_util.cc32
1 files changed, 26 insertions, 6 deletions
diff --git a/src/node_util.cc b/src/node_util.cc
index 591f3e3b5e..5adecf4d97 100644
--- a/src/node_util.cc
+++ b/src/node_util.cc
@@ -4,16 +4,23 @@
namespace node {
namespace util {
+using v8::ALL_PROPERTIES;
using v8::Array;
using v8::Context;
using v8::FunctionCallbackInfo;
using v8::Integer;
using v8::Local;
using v8::Object;
+using v8::ONLY_CONFIGURABLE;
+using v8::ONLY_ENUMERABLE;
+using v8::ONLY_WRITABLE;
using v8::Private;
using v8::Promise;
using v8::Proxy;
+using v8::SKIP_STRINGS;
+using v8::SKIP_SYMBOLS;
using v8::String;
+using v8::Uint32;
using v8::Value;
static void GetOwnNonIndexProperties(
@@ -21,17 +28,19 @@ static void GetOwnNonIndexProperties(
Environment* env = Environment::GetCurrent(args);
Local<Context> context = env->context();
- if (!args[0]->IsObject())
- return;
+ CHECK(args[0]->IsObject());
+ CHECK(args[1]->IsUint32());
+
+ Local<Object> object = args[0].As<Object>();
- v8::Local<v8::Object> object = args[0].As<v8::Object>();
+ Local<Array> properties;
- // Return only non-enumerable properties by default.
- v8::Local<v8::Array> properties;
+ v8::PropertyFilter filter =
+ static_cast<v8::PropertyFilter>(args[1].As<Uint32>()->Value());
if (!object->GetPropertyNames(
context, v8::KeyCollectionMode::kOwnOnly,
- v8::ONLY_ENUMERABLE,
+ filter,
v8::IndexFilter::kSkipIndices)
.ToLocal(&properties)) {
return;
@@ -209,6 +218,17 @@ void Initialize(Local<Object> target,
WatchdogHasPendingSigint);
env->SetMethod(target, "safeGetenv", SafeGetenv);
+
+ Local<Object> constants = Object::New(env->isolate());
+ NODE_DEFINE_CONSTANT(constants, ALL_PROPERTIES);
+ NODE_DEFINE_CONSTANT(constants, ONLY_WRITABLE);
+ NODE_DEFINE_CONSTANT(constants, ONLY_ENUMERABLE);
+ NODE_DEFINE_CONSTANT(constants, ONLY_CONFIGURABLE);
+ NODE_DEFINE_CONSTANT(constants, SKIP_STRINGS);
+ NODE_DEFINE_CONSTANT(constants, SKIP_SYMBOLS);
+ target->Set(context,
+ FIXED_ONE_BYTE_STRING(env->isolate(), "propertyFilter"),
+ constants).FromJust();
}
} // namespace util