File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -739,6 +739,9 @@ function setupReverseSearch(repl) {
739739 return { reverseSearch } ;
740740}
741741
742+ const startsWithBraceRegExp = / ^ \s * { / ;
743+ const endsWithSemicolonRegExp = / ; \s * $ / ;
744+
742745/**
743746 * Checks if some provided code represents an object literal.
744747 * This is helpful to prevent confusing repl code evaluations where
@@ -748,8 +751,8 @@ function setupReverseSearch(repl) {
748751 * @returns {boolean } true if the code represents an object literal, false otherwise
749752 */
750753function isObjectLiteral ( code ) {
751- return RegExpPrototypeExec ( / ^ \s * { / , code ) !== null &&
752- RegExpPrototypeExec ( / ; \s * $ / , code ) === null ;
754+ return RegExpPrototypeExec ( startsWithBraceRegExp , code ) !== null &&
755+ RegExpPrototypeExec ( endsWithSemicolonRegExp , code ) === null ;
753756}
754757
755758module . exports = {
You can’t perform that action at this time.
0 commit comments