Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e0fffca

Browse filesBrowse files
evanlucasjasnell
authored andcommitted
util: fix for inspecting promises
The upgrade to v8 4.6 removes ObjectIsPromise. This change utilizes v8::Value::IsPromise to verify that the argument is indeed a promise. PR-URL: #3221 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
1 parent 18a8b2e commit e0fffca
Copy full SHA for e0fffca

File tree

Expand file treeCollapse file tree

2 files changed

+7
-5
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+7
-5
lines changed
Open diff view settings
Collapse file

‎lib/util.js‎

Copy file name to clipboardExpand all lines: lib/util.js
+2-5Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ const internalUtil = require('internal/util');
66
const binding = process.binding('util');
77

88
var Debug;
9-
var ObjectIsPromise;
109

1110
const formatRegExp = /%[sdj%]/g;
1211
exports.format = function(f) {
@@ -189,16 +188,14 @@ function getConstructorOf(obj) {
189188
function ensureDebugIsInitialized() {
190189
if (Debug === undefined) {
191190
const runInDebugContext = require('vm').runInDebugContext;
192-
const result = runInDebugContext('[Debug, ObjectIsPromise]');
193-
Debug = result[0];
194-
ObjectIsPromise = result[1];
191+
Debug = runInDebugContext('Debug');
195192
}
196193
}
197194

198195

199196
function inspectPromise(p) {
200197
ensureDebugIsInitialized();
201-
if (!ObjectIsPromise(p))
198+
if (!binding.isPromise(p))
202199
return null;
203200
const mirror = Debug.MakeMirror(p, true);
204201
return {status: mirror.status(), value: mirror.promiseValue().value_};
Collapse file

‎src/node_util.cc‎

Copy file name to clipboardExpand all lines: src/node_util.cc
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,18 @@ static void IsSetIterator(const FunctionCallbackInfo<Value>& args) {
2323
args.GetReturnValue().Set(args[0]->IsSetIterator());
2424
}
2525

26+
static void IsPromise(const FunctionCallbackInfo<Value>& args) {
27+
CHECK_EQ(1, args.Length());
28+
args.GetReturnValue().Set(args[0]->IsPromise());
29+
}
2630

2731
void Initialize(Local<Object> target,
2832
Local<Value> unused,
2933
Local<Context> context) {
3034
Environment* env = Environment::GetCurrent(context);
3135
env->SetMethod(target, "isMapIterator", IsMapIterator);
3236
env->SetMethod(target, "isSetIterator", IsSetIterator);
37+
env->SetMethod(target, "isPromise", IsPromise);
3338
}
3439

3540
} // namespace util

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.