|
45 | 45 | const {
|
46 | 46 | ArrayPrototypeAt,
|
47 | 47 | ArrayPrototypeFilter,
|
48 |
| - ArrayPrototypeFindIndex, |
| 48 | + ArrayPrototypeFindLastIndex, |
49 | 49 | ArrayPrototypeForEach,
|
50 | 50 | ArrayPrototypeIncludes,
|
51 | 51 | ArrayPrototypeJoin,
|
52 | 52 | ArrayPrototypeMap,
|
53 | 53 | ArrayPrototypePop,
|
54 | 54 | ArrayPrototypePush,
|
55 | 55 | ArrayPrototypePushApply,
|
56 |
| - ArrayPrototypeReverse, |
57 | 56 | ArrayPrototypeShift,
|
58 | 57 | ArrayPrototypeSlice,
|
59 | 58 | ArrayPrototypeSome,
|
60 | 59 | ArrayPrototypeSort,
|
61 |
| - ArrayPrototypeSplice, |
62 | 60 | ArrayPrototypeUnshift,
|
63 | 61 | Boolean,
|
64 |
| - Error, |
| 62 | + Error: MainContextError, |
65 | 63 | FunctionPrototypeBind,
|
66 | 64 | JSONStringify,
|
67 | 65 | MathMaxApply,
|
@@ -630,10 +628,10 @@ function REPLServer(prompt,
|
630 | 628 | if (self.breakEvalOnSigint) {
|
631 | 629 | const interrupt = new Promise((resolve, reject) => {
|
632 | 630 | sigintListener = () => {
|
633 |
| - const tmp = Error.stackTraceLimit; |
634 |
| - if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = 0; |
| 631 | + const tmp = MainContextError.stackTraceLimit; |
| 632 | + if (isErrorStackTraceLimitWritable()) MainContextError.stackTraceLimit = 0; |
635 | 633 | const err = new ERR_SCRIPT_EXECUTION_INTERRUPTED();
|
636 |
| - if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = tmp; |
| 634 | + if (isErrorStackTraceLimitWritable()) MainContextError.stackTraceLimit = tmp; |
637 | 635 | reject(err);
|
638 | 636 | };
|
639 | 637 | prioritizedSigintQueue.add(sigintListener);
|
@@ -679,23 +677,23 @@ function REPLServer(prompt,
|
679 | 677 | if (typeof stackFrames === 'object') {
|
680 | 678 | // Search from the bottom of the call stack to
|
681 | 679 | // find the first frame with a null function name
|
682 |
| - const idx = ArrayPrototypeFindIndex( |
683 |
| - ArrayPrototypeReverse(stackFrames), |
| 680 | + const idx = ArrayPrototypeFindLastIndex( |
| 681 | + stackFrames, |
684 | 682 | (frame) => frame.getFunctionName() === null,
|
685 | 683 | );
|
686 | 684 | // If found, get rid of it and everything below it
|
687 |
| - frames = ArrayPrototypeSplice(stackFrames, idx + 1); |
| 685 | + frames = ArrayPrototypeSlice(stackFrames, 0, idx); |
688 | 686 | } else {
|
689 | 687 | frames = stackFrames;
|
690 | 688 | }
|
691 | 689 | // FIXME(devsnek): this is inconsistent with the checks
|
692 | 690 | // that the real prepareStackTrace dispatch uses in
|
693 | 691 | // lib/internal/errors.js.
|
694 |
| - if (typeof Error.prepareStackTrace === 'function') { |
695 |
| - return Error.prepareStackTrace(error, frames); |
| 692 | + if (typeof MainContextError.prepareStackTrace === 'function') { |
| 693 | + return MainContextError.prepareStackTrace(error, frames); |
696 | 694 | }
|
697 |
| - ArrayPrototypePush(frames, error); |
698 |
| - return ArrayPrototypeJoin(ArrayPrototypeReverse(frames), '\n at '); |
| 695 | + ArrayPrototypeUnshift(frames, error); |
| 696 | + return ArrayPrototypeJoin(frames, '\n at '); |
699 | 697 | });
|
700 | 698 | decorateErrorStack(e);
|
701 | 699 |
|
|
0 commit comments