Skip to content

Commit d6334cb

Browse files
committed
repl: replace native methods with primordials
Replace native methods with primordials.
1 parent 879b95e commit d6334cb

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

lib/internal/repl/completion.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -540,14 +540,14 @@ function findExpressionCompleteTarget(code) {
540540
// such code can't generate a valid AST so we need to strip
541541
// the suffix, run this function's logic and add back the
542542
// optional chaining operator to the result if present
543-
const result = findExpressionCompleteTarget(code.slice(0, -2));
543+
const result = findExpressionCompleteTarget(StringPrototypeSlice(code, 0, -2));
544544
return !result ? result : `${result}?.`;
545545
}
546546

547547
// The code ends with a dot, such code can't generate a valid AST
548548
// so we need to strip the suffix, run this function's logic and
549549
// add back the dot to the result if present
550-
const result = findExpressionCompleteTarget(code.slice(0, -1));
550+
const result = findExpressionCompleteTarget(StringPrototypeSlice(code, 0, -1));
551551
return !result ? result : `${result}.`;
552552
}
553553

@@ -587,7 +587,7 @@ function findExpressionCompleteTarget(code) {
587587
// want to potentially complete on, so let's re-run the function's logic on that
588588
if (lastBodyStatement.type === 'ExpressionStatement' && lastBodyStatement.expression.right) {
589589
const exprRight = lastBodyStatement.expression.right;
590-
const exprRightCode = code.slice(exprRight.start, exprRight.end);
590+
const exprRightCode = StringPrototypeSlice(code, exprRight.start, exprRight.end);
591591
return findExpressionCompleteTarget(exprRightCode);
592592
}
593593

@@ -599,7 +599,7 @@ function findExpressionCompleteTarget(code) {
599599
// If there is no initialization we can simply return
600600
return null;
601601
}
602-
const lastDeclarationInitCode = code.slice(lastDeclarationInit.start, lastDeclarationInit.end);
602+
const lastDeclarationInitCode = StringPrototypeSlice(code, lastDeclarationInit.start, lastDeclarationInit.end);
603603
return findExpressionCompleteTarget(lastDeclarationInitCode);
604604
}
605605

@@ -609,7 +609,7 @@ function findExpressionCompleteTarget(code) {
609609
lastBodyStatement.expression.type === 'UnaryExpression' &&
610610
lastBodyStatement.expression.argument) {
611611
const argument = lastBodyStatement.expression.argument;
612-
const argumentCode = code.slice(argument.start, argument.end);
612+
const argumentCode = StringPrototypeSlice(code, argument.start, argument.end);
613613
return findExpressionCompleteTarget(argumentCode);
614614
}
615615

@@ -619,7 +619,7 @@ function findExpressionCompleteTarget(code) {
619619
lastBodyStatement.expression.type === 'NewExpression' &&
620620
lastBodyStatement.expression.callee) {
621621
const callee = lastBodyStatement.expression.callee;
622-
const calleeCode = code.slice(callee.start, callee.end);
622+
const calleeCode = StringPrototypeSlice(code, callee.start, callee.end);
623623
return findExpressionCompleteTarget(calleeCode);
624624
}
625625

@@ -641,7 +641,7 @@ function findExpressionCompleteTarget(code) {
641641
// If any of the above early returns haven't activated then it means that
642642
// the potential complete target is the full code (e.g. the code represents
643643
// a simple partial identifier, a member expression, etc...)
644-
return code.slice(lastBodyStatement.start, lastBodyStatement.end);
644+
return StringPrototypeSlice(code, lastBodyStatement.start, lastBodyStatement.end);
645645
}
646646

647647
/**
@@ -667,7 +667,7 @@ function includesProxiesOrGetters(expr, exprStr, evalFn, ctx, callback) {
667667
// The object itself is a member expression, so we need to recurse (e.g. the expression is `obj.foo.bar`)
668668
return includesProxiesOrGetters(
669669
expr.object,
670-
exprStr.slice(0, expr.object.end),
670+
StringPrototypeSlice(exprStr, 0, expr.object.end),
671671
evalFn,
672672
ctx,
673673
(includes, lastEvaledObj) => {
@@ -748,7 +748,7 @@ function includesProxiesOrGetters(expr, exprStr, evalFn, ctx, callback) {
748748
// Arguably this behavior should not be too surprising, but if it turns out that it is,
749749
// then we can revisit this behavior and add logic to analyze the property expression
750750
// and eval it only if we can confidently say that it can't have any side effects
751-
`try { ${exprStr.slice(astProp.start, astProp.end)} } catch {} `,
751+
`try { ${StringPrototypeSlice(exprStr, astProp.start, astProp.end)} } catch {} `,
752752
ctx,
753753
getREPLResourceName(),
754754
(err, evaledProp) => {

0 commit comments

Comments
 (0)