@@ -28,14 +28,15 @@ const {
28
28
ReflectGetOwnPropertyDescriptor,
29
29
ReflectOwnKeys,
30
30
RegExpPrototypeExec,
31
- RegExpPrototypeSymbolReplace,
32
31
SafeMap,
33
- SafePromiseAll,
32
+ SafePromiseAllReturnArrayLike,
33
+ SafePromiseAllReturnVoid,
34
34
String,
35
35
StringFromCharCode,
36
36
StringPrototypeEndsWith,
37
37
StringPrototypeIncludes,
38
38
StringPrototypeRepeat,
39
+ StringPrototypeReplaceAll,
39
40
StringPrototypeSlice,
40
41
StringPrototypeSplit,
41
42
StringPrototypeStartsWith,
@@ -53,7 +54,7 @@ const Repl = require('repl');
53
54
const vm = require ( 'vm' ) ;
54
55
const { fileURLToPath } = require ( 'internal/url' ) ;
55
56
56
- const { customInspectSymbol } = require ( 'internal/util' ) ;
57
+ const { customInspectSymbol, SideEffectFreeRegExpPrototypeSymbolReplace } = require ( 'internal/util' ) ;
57
58
const { inspect : utilInspect } = require ( 'internal/util/inspect' ) ;
58
59
const debuglog = require ( 'internal/util/debuglog' ) . debuglog ( 'inspect' ) ;
59
60
@@ -121,7 +122,7 @@ const {
121
122
} = internalBinding ( 'builtins' ) ;
122
123
const NATIVES = internalBinding ( 'natives' ) ;
123
124
function isNativeUrl ( url ) {
124
- url = RegExpPrototypeSymbolReplace ( / \. j s $ / , url , '' ) ;
125
+ url = SideEffectFreeRegExpPrototypeSymbolReplace ( / \. j s $ / , url , '' ) ;
125
126
126
127
return StringPrototypeStartsWith ( url , 'node:internal/' ) ||
127
128
ArrayPrototypeIncludes ( PUBLIC_BUILTINS , url ) ||
@@ -159,8 +160,8 @@ function markSourceColumn(sourceText, position, useColors) {
159
160
160
161
// Colourize char if stdout supports colours
161
162
if ( useColors ) {
162
- tail = RegExpPrototypeSymbolReplace ( / ( .+ ?) ( [ ^ \w ] | $ ) / , tail ,
163
- '\u001b[32m$1\u001b[39m$2' ) ;
163
+ tail = SideEffectFreeRegExpPrototypeSymbolReplace ( / ( .+ ?) ( [ ^ \w ] | $ ) / , tail ,
164
+ '\u001b[32m$1\u001b[39m$2' ) ;
164
165
}
165
166
166
167
// Return source line with coloured char at `position`
@@ -340,9 +341,9 @@ class ScopeSnapshot {
340
341
StringPrototypeSlice ( this . type , 1 ) ;
341
342
const name = this . name ? `<${ this . name } >` : '' ;
342
343
const prefix = `${ type } ${ name } ` ;
343
- return RegExpPrototypeSymbolReplace ( / ^ M a p / ,
344
- utilInspect ( this . properties , opts ) ,
345
- prefix ) ;
344
+ return SideEffectFreeRegExpPrototypeSymbolReplace ( / ^ M a p / ,
345
+ utilInspect ( this . properties , opts ) ,
346
+ prefix ) ;
346
347
}
347
348
}
348
349
@@ -517,7 +518,7 @@ function createRepl(inspector) {
517
518
}
518
519
519
520
loadScopes ( ) {
520
- return SafePromiseAll (
521
+ return SafePromiseAllReturnArrayLike (
521
522
ArrayPrototypeFilter (
522
523
this . scopeChain ,
523
524
( scope ) => scope . type !== 'global'
@@ -656,14 +657,14 @@ function createRepl(inspector) {
656
657
( error ) => `<${ error . message } >` ) ;
657
658
const lastIndex = watchedExpressions . length - 1 ;
658
659
659
- const values = await SafePromiseAll ( watchedExpressions , inspectValue ) ;
660
+ const values = await SafePromiseAllReturnArrayLike ( watchedExpressions , inspectValue ) ;
660
661
const lines = ArrayPrototypeMap ( watchedExpressions , ( expr , idx ) => {
661
662
const prefix = `${ leftPad ( idx , ' ' , lastIndex ) } : ${ expr } =` ;
662
663
const value = inspect ( values [ idx ] ) ;
663
664
if ( ! StringPrototypeIncludes ( value , '\n' ) ) {
664
665
return `${ prefix } ${ value } ` ;
665
666
}
666
- return `${ prefix } \n ${ RegExpPrototypeSymbolReplace ( / \n / g , value , '\n ' ) } ` ;
667
+ return `${ prefix } \n ${ StringPrototypeReplaceAll ( value , '\n' , '\n ' ) } ` ;
667
668
} ) ;
668
669
const valueList = ArrayPrototypeJoin ( lines , '\n' ) ;
669
670
return verbose ? `Watchers:\n${ valueList } \n` : valueList ;
@@ -805,8 +806,8 @@ function createRepl(inspector) {
805
806
registerBreakpoint ) ;
806
807
}
807
808
808
- const escapedPath = RegExpPrototypeSymbolReplace ( / ( [ / \\ . ? * ( ) ^ $ { } | [ \] ] ) / g,
809
- script , '\\$1' ) ;
809
+ const escapedPath = SideEffectFreeRegExpPrototypeSymbolReplace ( / ( [ / \\ . ? * ( ) ^ $ { } | [ \] ] ) / g,
810
+ script , '\\$1' ) ;
810
811
const urlRegex = `^(.*[\\/\\\\])?${ escapedPath } $` ;
811
812
812
813
return PromisePrototypeThen (
@@ -860,9 +861,9 @@ function createRepl(inspector) {
860
861
location . lineNumber + 1 ) ) ;
861
862
if ( ! newBreakpoints . length ) return PromiseResolve ( ) ;
862
863
return PromisePrototypeThen (
863
- SafePromiseAll ( newBreakpoints ) ,
864
- ( results ) => {
865
- print ( `${ results . length } breakpoints restored.` ) ;
864
+ SafePromiseAllReturnVoid ( newBreakpoints ) ,
865
+ ( ) => {
866
+ print ( `${ newBreakpoints . length } breakpoints restored.` ) ;
866
867
} ) ;
867
868
}
868
869
@@ -896,7 +897,7 @@ function createRepl(inspector) {
896
897
897
898
inspector . suspendReplWhile ( ( ) =>
898
899
PromisePrototypeThen (
899
- SafePromiseAll ( [ formatWatchers ( true ) , selectedFrame . list ( 2 ) ] ) ,
900
+ SafePromiseAllReturnArrayLike ( [ formatWatchers ( true ) , selectedFrame . list ( 2 ) ] ) ,
900
901
( { 0 : watcherList , 1 : context } ) => {
901
902
const breakContext = watcherList ?
902
903
`${ watcherList } \n${ inspect ( context ) } ` :
0 commit comments