| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 18a8b2e commit e0fffca
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,7 +6,6 @@ const internalUtil = require('internal/util'); | |||
| 6 | 6 | const binding = process.binding('util'); | |
| 7 | 7 | ||
| 8 | 8 | var Debug; | |
| 9 | - var ObjectIsPromise; | ||
| 10 | 9 | ||
| 11 | 10 | const formatRegExp = /%[sdj%]/g; | |
| 12 | 11 | exports.format = function(f) { | |
@@ -189,16 +188,14 @@ function getConstructorOf(obj) { | |||
| 189 | 188 | function ensureDebugIsInitialized() { | |
| 190 | 189 | if (Debug === undefined) { | |
| 191 | 190 | const runInDebugContext = require('vm').runInDebugContext; | |
| 192 | - const result = runInDebugContext('[Debug, ObjectIsPromise]'); | ||
| 193 | - Debug = result[0]; | ||
| 194 | - ObjectIsPromise = result[1]; | ||
| 191 | + Debug = runInDebugContext('Debug'); | ||
| 195 | 192 | } | |
| 196 | 193 | } | |
| 197 | 194 | ||
| 198 | 195 | ||
| 199 | 196 | function inspectPromise(p) { | |
| 200 | 197 | ensureDebugIsInitialized(); | |
| 201 | - if (!ObjectIsPromise(p)) | ||
| 198 | + if (!binding.isPromise(p)) | ||
| 202 | 199 | return null; | |
| 203 | 200 | const mirror = Debug.MakeMirror(p, true); | |
| 204 | 201 | return {status: mirror.status(), value: mirror.promiseValue().value_}; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -23,13 +23,18 @@ static void IsSetIterator(const FunctionCallbackInfo<Value>& args) { | |||
| 23 | 23 | args.GetReturnValue().Set(args[0]->IsSetIterator()); | |
| 24 | 24 | } | |
| 25 | 25 | ||
| 26 | + static void IsPromise(const FunctionCallbackInfo<Value>& args) { | ||
| 27 | + CHECK_EQ(1, args.Length()); | ||
| 28 | + args.GetReturnValue().Set(args[0]->IsPromise()); | ||
| 29 | + } | ||
| 26 | 30 | ||
| 27 | 31 | void Initialize(Local<Object> target, | |
| 28 | 32 | Local<Value> unused, | |
| 29 | 33 | Local<Context> context) { | |
| 30 | 34 | Environment* env = Environment::GetCurrent(context); | |
| 31 | 35 | env->SetMethod(target, "isMapIterator", IsMapIterator); | |
| 32 | 36 | env->SetMethod(target, "isSetIterator", IsSetIterator); | |
| 37 | + env->SetMethod(target, "isPromise", IsPromise); | ||
| 33 | 38 | } | |
| 34 | 39 | ||
| 35 | 40 | } // namespace util | |
| Back | FazBrowse Home | New Git URL |
0 commit comments