summaryrefslogtreecommitdiff
path: root/src/node_util.cc
diff options
context:
space:
mode:
authorEvan Lucas <evanlucas@me.com>2015-12-01 08:11:18 -0600
committerEvan Lucas <evanlucas@me.com>2015-12-02 06:11:45 -0600
commit24012a879d2fe17287a857ee20f696a78590db15 (patch)
tree1a7f0649a2e7453cac6e1516a61582668381be84 /src/node_util.cc
parent451254ed25a3b9860d7b45dade6ed05b629d6bbd (diff)
downloadandroid-node-v8-24012a879d2fe17287a857ee20f696a78590db15.tar.gz
android-node-v8-24012a879d2fe17287a857ee20f696a78590db15.tar.bz2
android-node-v8-24012a879d2fe17287a857ee20f696a78590db15.zip
util: make inspect more reliable
34a35919e165cba6d5972e004e6b2cbdf2f4c65a added pretty printing for TypedArray, ArrayBuffer, and DataView. This change allows inspecting those across different contexts. Since instanceof does not work across contexts, we can use v8::Value::IsTypedArray, v8::Value::IsArrayBuffer, and v8::Value::IsDataView PR-URL: https://github.com/nodejs/node/pull/4098 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'src/node_util.cc')
-rw-r--r--src/node_util.cc21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/node_util.cc b/src/node_util.cc
index a520b8d5f3..dad005d760 100644
--- a/src/node_util.cc
+++ b/src/node_util.cc
@@ -30,6 +30,24 @@ static void IsPromise(const FunctionCallbackInfo<Value>& args) {
}
+static void IsTypedArray(const FunctionCallbackInfo<Value>& args) {
+ CHECK_EQ(1, args.Length());
+ args.GetReturnValue().Set(args[0]->IsTypedArray());
+}
+
+
+static void IsArrayBuffer(const FunctionCallbackInfo<Value>& args) {
+ CHECK_EQ(1, args.Length());
+ args.GetReturnValue().Set(args[0]->IsArrayBuffer());
+}
+
+
+static void IsDataView(const FunctionCallbackInfo<Value>& args) {
+ CHECK_EQ(1, args.Length());
+ args.GetReturnValue().Set(args[0]->IsDataView());
+}
+
+
static void GetHiddenValue(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
@@ -53,6 +71,9 @@ void Initialize(Local<Object> target,
env->SetMethod(target, "isMapIterator", IsMapIterator);
env->SetMethod(target, "isSetIterator", IsSetIterator);
env->SetMethod(target, "isPromise", IsPromise);
+ env->SetMethod(target, "isTypedArray", IsTypedArray);
+ env->SetMethod(target, "isArrayBuffer", IsArrayBuffer);
+ env->SetMethod(target, "isDataView", IsDataView);
env->SetMethod(target, "getHiddenValue", GetHiddenValue);
}