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 1deb6b7

Browse filesBrowse files
aduh95danielleadams
authored andcommitted
repl: use SafePromiseAll and SafePromiseRace
PR-URL: #43758 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent 50b3750 commit 1deb6b7
Copy full SHA for 1deb6b7

File tree

Expand file treeCollapse file tree

2 files changed

+19
-25
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+19
-25
lines changed
Open diff view settings
Collapse file

‎lib/internal/debugger/inspect_repl.js‎

Copy file name to clipboardExpand all lines: lib/internal/debugger/inspect_repl.js
+17-23Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,15 @@ const {
2323
ObjectKeys,
2424
ObjectValues,
2525
Promise,
26-
PromiseAll,
2726
PromisePrototypeCatch,
2827
PromisePrototypeThen,
2928
PromiseResolve,
3029
ReflectGetOwnPropertyDescriptor,
3130
ReflectOwnKeys,
3231
RegExpPrototypeExec,
3332
RegExpPrototypeSymbolReplace,
34-
SafeArrayIterator,
3533
SafeMap,
34+
SafePromiseAll,
3635
String,
3736
StringFromCharCode,
3837
StringPrototypeEndsWith,
@@ -519,22 +518,19 @@ function createRepl(inspector) {
519518
}
520519

521520
loadScopes() {
522-
return PromiseAll(
523-
new SafeArrayIterator(ArrayPrototypeMap(
524-
ArrayPrototypeFilter(
525-
this.scopeChain,
526-
(scope) => scope.type !== 'global'
527-
),
528-
async (scope) => {
529-
const { objectId } = scope.object;
530-
const { result } = await Runtime.getProperties({
531-
objectId,
532-
generatePreview: true,
533-
});
534-
return new ScopeSnapshot(scope, result);
535-
})
536-
)
537-
);
521+
return SafePromiseAll(
522+
ArrayPrototypeFilter(
523+
this.scopeChain,
524+
(scope) => scope.type !== 'global'
525+
),
526+
async (scope) => {
527+
const { objectId } = scope.object;
528+
const { result } = await Runtime.getProperties({
529+
objectId,
530+
generatePreview: true,
531+
});
532+
return new ScopeSnapshot(scope, result);
533+
});
538534
}
539535

540536
list(delta = 5) {
@@ -661,8 +657,7 @@ function createRepl(inspector) {
661657
(error) => `<${error.message}>`);
662658
const lastIndex = watchedExpressions.length - 1;
663659

664-
const values = await PromiseAll(new SafeArrayIterator(
665-
ArrayPrototypeMap(watchedExpressions, inspectValue)));
660+
const values = await SafePromiseAll(watchedExpressions, inspectValue);
666661
const lines = ArrayPrototypeMap(watchedExpressions, (expr, idx) => {
667662
const prefix = `${leftPad(idx, ' ', lastIndex)}: ${expr} =`;
668663
const value = inspect(values[idx]);
@@ -866,7 +861,7 @@ function createRepl(inspector) {
866861
location.lineNumber + 1));
867862
if (!newBreakpoints.length) return PromiseResolve();
868863
return PromisePrototypeThen(
869-
PromiseAll(new SafeArrayIterator(newBreakpoints)),
864+
SafePromiseAll(newBreakpoints),
870865
(results) => {
871866
print(`${results.length} breakpoints restored.`);
872867
});
@@ -902,8 +897,7 @@ function createRepl(inspector) {
902897

903898
inspector.suspendReplWhile(() =>
904899
PromisePrototypeThen(
905-
PromiseAll(new SafeArrayIterator(
906-
[formatWatchers(true), selectedFrame.list(2)])),
900+
SafePromiseAll([formatWatchers(true), selectedFrame.list(2)]),
907901
({ 0: watcherList, 1: context }) => {
908902
const breakContext = watcherList ?
909903
`${watcherList}\n${inspect(context)}` :
Collapse file

‎lib/repl.js‎

Copy file name to clipboardExpand all lines: lib/repl.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ const {
7474
ObjectKeys,
7575
ObjectSetPrototypeOf,
7676
Promise,
77-
PromiseRace,
7877
ReflectApply,
7978
RegExp,
8079
RegExpPrototypeExec,
8180
RegExpPrototypeSymbolReplace,
8281
RegExpPrototypeSymbolSplit,
82+
SafePromiseRace,
8383
SafeSet,
8484
SafeWeakSet,
8585
StringPrototypeCharAt,
@@ -611,7 +611,7 @@ function REPLServer(prompt,
611611
};
612612
prioritizedSigintQueue.add(sigintListener);
613613
});
614-
promise = PromiseRace([promise, interrupt]);
614+
promise = SafePromiseRace([promise, interrupt]);
615615
}
616616

617617
(async () => {

0 commit comments

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