| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d910672 commit f46649b
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -63,6 +63,7 @@ const { | |||
| 63 | 63 | kRejected, | |
| 64 | 64 | previewEntries, | |
| 65 | 65 | getConstructorName: internalGetConstructorName, | |
| 66 | + getExternalValue, | ||
| 66 | 67 | propertyFilter: { | |
| 67 | 68 | ALL_PROPERTIES, | |
| 68 | 69 | ONLY_ENUMERABLE | |
@@ -977,8 +978,10 @@ function formatRaw(ctx, value, recurseTimes, typedArray) { | |||
| 977 | 978 | } | |
| 978 | 979 | } else { | |
| 979 | 980 | if (keys.length === 0 && protoProps === undefined) { | |
| 980 | - if (isExternal(value)) | ||
| 981 | - return ctx.stylize('[External]', 'special'); | ||
| 981 | + if (isExternal(value)) { | ||
| 982 | + const address = getExternalValue(value).toString(16); | ||
| 983 | + return ctx.stylize(`[External: ${address}]`, 'special'); | ||
| 984 | + } | ||
| 982 | 985 | return `${getCtxStyle(value, constructor, tag)}{}`; | |
| 983 | 986 | } | |
| 984 | 987 | braces[0] = `${getCtxStyle(value, constructor, tag)}{`; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,8 +8,10 @@ namespace util { | |||
| 8 | 8 | using v8::ALL_PROPERTIES; | |
| 9 | 9 | using v8::Array; | |
| 10 | 10 | using v8::ArrayBufferView; | |
| 11 | + using v8::BigInt; | ||
| 11 | 12 | using v8::Boolean; | |
| 12 | 13 | using v8::Context; | |
| 14 | + using v8::External; | ||
| 13 | 15 | using v8::FunctionCallbackInfo; | |
| 14 | 16 | using v8::FunctionTemplate; | |
| 15 | 17 | using v8::Global; | |
@@ -18,6 +20,7 @@ using v8::Integer; | |||
| 18 | 20 | using v8::Isolate; | |
| 19 | 21 | using v8::KeyCollectionMode; | |
| 20 | 22 | using v8::Local; | |
| 23 | + using v8::MaybeLocal; | ||
| 21 | 24 | using v8::Object; | |
| 22 | 25 | using v8::ONLY_CONFIGURABLE; | |
| 23 | 26 | using v8::ONLY_ENUMERABLE; | |
@@ -67,6 +70,18 @@ static void GetConstructorName( | |||
| 67 | 70 | args.GetReturnValue().Set(name); | |
| 68 | 71 | } | |
| 69 | 72 | ||
| 73 | + static void GetExternalValue( | ||
| 74 | + const FunctionCallbackInfo<Value>& args) { | ||
| 75 | + CHECK(args[0]->IsExternal()); | ||
| 76 | + Isolate* isolate = args.GetIsolate(); | ||
| 77 | + Local<External> external = args[0].As<External>(); | ||
| 78 | + | ||
| 79 | + void* ptr = external->Value(); | ||
| 80 | + uint64_t value = reinterpret_cast<uint64_t>(ptr); | ||
| 81 | + Local<BigInt> ret = BigInt::NewFromUnsigned(isolate, value); | ||
| 82 | + args.GetReturnValue().Set(ret); | ||
| 83 | + } | ||
| 84 | + | ||
| 70 | 85 | static void GetPromiseDetails(const FunctionCallbackInfo<Value>& args) { | |
| 71 | 86 | // Return undefined if it's not a Promise. | |
| 72 | 87 | if (!args[0]->IsPromise()) | |
@@ -296,6 +311,7 @@ void Initialize(Local<Object> target, | |||
| 296 | 311 | env->SetMethodNoSideEffect(target, "getOwnNonIndexProperties", | |
| 297 | 312 | GetOwnNonIndexProperties); | |
| 298 | 313 | env->SetMethodNoSideEffect(target, "getConstructorName", GetConstructorName); | |
| 314 | + env->SetMethodNoSideEffect(target, "getExternalValue", GetExternalValue); | ||
| 299 | 315 | env->SetMethod(target, "sleep", Sleep); | |
| 300 | 316 | ||
| 301 | 317 | env->SetMethod(target, "arrayBufferViewHasBuffer", ArrayBufferViewHasBuffer); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -147,8 +147,8 @@ assert.strictEqual( | |||
| 147 | 147 | "[String: 'hello'] { [length]: 5, [Symbol(foo)]: 123 }" | |
| 148 | 148 | ); | |
| 149 | 149 | ||
| 150 | - assert.strictEqual(util.inspect((new JSStream())._externalStream), | ||
| 151 | - '[External]'); | ||
| 150 | + assert.match(util.inspect((new JSStream())._externalStream), | ||
| 151 | + /^\[External: [0-9a-f]+\]$/); | ||
| 152 | 152 | ||
| 153 | 153 | { | |
| 154 | 154 | const regexp = /regexp/; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments