File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,6 @@ const internalUtil = require('internal/util');
66const binding = process . binding ( 'util' ) ;
77
88var Debug ;
9- var ObjectIsPromise ;
109
1110const formatRegExp = / % [ s d j % ] / g;
1211exports . format = function ( f ) {
@@ -189,16 +188,14 @@ function getConstructorOf(obj) {
189188function 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
199196function 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_ } ;
Original file line number Diff line number Diff 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
2731void 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
You can’t perform that action at this time.
0 commit comments