diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2019-05-01 22:21:00 +0200 |
---|---|---|
committer | ZYSzys <zyszys98@gmail.com> | 2019-05-04 23:45:47 +0800 |
commit | 7910b025a26839483f4ae1d50a60d00c8d32f81b (patch) | |
tree | 6392659347e456a7ebaf68af3dc4ca1f90920b94 /src/node_util.cc | |
parent | eda4d3c59e02769a99cb58c369674a8f8f25974c (diff) | |
download | android-node-v8-7910b025a26839483f4ae1d50a60d00c8d32f81b.tar.gz android-node-v8-7910b025a26839483f4ae1d50a60d00c8d32f81b.tar.bz2 android-node-v8-7910b025a26839483f4ae1d50a60d00c8d32f81b.zip |
util: inspect constructor closer
This adds an extra check to `util.inspect` to closer inspect object
constructors in case there's not much other information about the
constructor.
PR-URL: https://github.com/nodejs/node/pull/27522
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Diffstat (limited to 'src/node_util.cc')
-rw-r--r-- | src/node_util.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/node_util.cc b/src/node_util.cc index 180c58c416..0c498e2838 100644 --- a/src/node_util.cc +++ b/src/node_util.cc @@ -58,6 +58,16 @@ static void GetOwnNonIndexProperties( args.GetReturnValue().Set(properties); } +static void GetConstructorName( + const FunctionCallbackInfo<Value>& args) { + CHECK(args[0]->IsObject()); + + Local<Object> object = args[0].As<Object>(); + Local<String> name = object->GetConstructorName(); + + args.GetReturnValue().Set(name); +} + static void GetPromiseDetails(const FunctionCallbackInfo<Value>& args) { // Return undefined if it's not a Promise. if (!args[0]->IsPromise()) @@ -262,6 +272,7 @@ void Initialize(Local<Object> target, env->SetMethodNoSideEffect(target, "previewEntries", PreviewEntries); env->SetMethodNoSideEffect(target, "getOwnNonIndexProperties", GetOwnNonIndexProperties); + env->SetMethodNoSideEffect(target, "getConstructorName", GetConstructorName); env->SetMethod(target, "arrayBufferViewHasBuffer", ArrayBufferViewHasBuffer); Local<Object> constants = Object::New(env->isolate()); |