| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a0b35bf commit d8ab4e1
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,7 +3,9 @@ | |||
| 3 | 3 | const uv = process.binding('uv'); | |
| 4 | 4 | const Buffer = require('buffer').Buffer; | |
| 5 | 5 | const internalUtil = require('internal/util'); | |
| 6 | + | ||
| 6 | 7 | var Debug; | |
| 8 | + var ObjectIsPromise; | ||
| 7 | 9 | ||
| 8 | 10 | const formatRegExp = /%[sdj%]/g; | |
| 9 | 11 | exports.format = function(f) { | |
@@ -183,11 +185,21 @@ function getConstructorOf(obj) { | |||
| 183 | 185 | } | |
| 184 | 186 | ||
| 185 | 187 | ||
| 188 | + function ensureDebugIsInitialized() { | ||
| 189 | + if (Debug === undefined) { | ||
| 190 | + const runInDebugContext = require('vm').runInDebugContext; | ||
| 191 | + const result = runInDebugContext('[Debug, ObjectIsPromise]'); | ||
| 192 | + Debug = result[0]; | ||
| 193 | + ObjectIsPromise = result[1]; | ||
| 194 | + } | ||
| 195 | + } | ||
| 196 | + | ||
| 197 | + | ||
| 186 | 198 | function inspectPromise(p) { | |
| 187 | - Debug = Debug || require('vm').runInDebugContext('Debug'); | ||
| 188 | - var mirror = Debug.MakeMirror(p, true); | ||
| 189 | - if (!mirror.isPromise()) | ||
| 199 | + ensureDebugIsInitialized(); | ||
| 200 | + if (!ObjectIsPromise(p)) | ||
| 190 | 201 | return null; | |
| 202 | + const mirror = Debug.MakeMirror(p, true); | ||
| 191 | 203 | return {status: mirror.status(), value: mirror.promiseValue().value_}; | |
| 192 | 204 | } | |
| 193 | 205 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments