@@ -96,6 +96,10 @@ const {
96
96
globalThis,
97
97
} = primordials ;
98
98
99
+ const {
100
+ isProxy,
101
+ } = require ( 'internal/util/types' ) ;
102
+
99
103
const { BuiltinModule } = require ( 'internal/bootstrap/realm' ) ;
100
104
const {
101
105
makeRequireFunction,
@@ -1623,29 +1627,28 @@ async function includesProxiesOrGetters(fullExpr, evalFn, context) {
1623
1627
let currentExpr = '' ;
1624
1628
for ( let i = 0 ; i < bits . length - 1 ; i ++ ) {
1625
1629
currentExpr += `${ i === 0 ? '' : '.' } ${ bits [ i ] } ` ;
1626
- const currentExprIsObject = await evalPromisified ( `try { ${ currentExpr } !== null && typeof ${ currentExpr } === 'object' } catch { false }` ) ;
1627
- if ( ! currentExprIsObject ) {
1628
- return false ;
1629
- }
1630
+ const currentResult = await new Promise ( ( resolve ) =>
1631
+ evalFn ( `try { ${ currentExpr } } catch { }` , context , getREPLResourceName ( ) , ( _ , currentObj ) => {
1632
+ if ( typeof currentObj !== 'object' || currentObj === null ) {
1633
+ return resolve ( false ) ;
1634
+ }
1630
1635
1631
- const currentExprIsProxy = await evalPromisified ( `require("node:util/types").isProxy(${ currentExpr } )` ) ;
1632
- if ( currentExprIsProxy ) {
1633
- return true ;
1634
- }
1636
+ if ( isProxy ( currentObj ) ) {
1637
+ return resolve ( true ) ;
1638
+ }
1635
1639
1636
- const typeOfNextBitGet = await evalPromisified ( `typeof Object.getOwnPropertyDescriptor(${ currentExpr } , '${ bits [ i + 1 ] } ')?.get` ) ;
1637
- const nextBitHasGetter = typeOfNextBitGet === 'function' ;
1638
- if ( nextBitHasGetter ) {
1639
- return true ;
1640
- }
1641
- }
1640
+ const nextBitHasGetter = typeof ObjectGetOwnPropertyDescriptor ( currentObj , bits [ i + 1 ] ) ?. get === 'function' ;
1641
+ if ( nextBitHasGetter ) {
1642
+ return resolve ( true ) ;
1643
+ }
1642
1644
1643
- function evalPromisified ( evalExpr ) {
1644
- return new Promise ( ( resolve , reject ) =>
1645
- evalFn ( evalExpr , context , getREPLResourceName ( ) , ( _ , res ) => {
1646
- resolve ( res ) ;
1645
+ return resolve ( ) ;
1647
1646
} ) ) ;
1647
+ if ( currentResult !== undefined ) {
1648
+ return currentResult ;
1649
+ }
1648
1650
}
1651
+ return false ;
1649
1652
}
1650
1653
1651
1654
REPLServer . prototype . completeOnEditorMode = ( callback ) => ( err , results ) => {
0 commit comments