Skip to content

Commit

Permalink
repl: remove unused function convertToContext
Browse files Browse the repository at this point in the history
PR-URL: #13434
Reviewed-By: Prince John Wesley <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
seishun committed Jun 5, 2017
1 parent 5ca836c commit 3d9e7bb
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 50 deletions.
2 changes: 1 addition & 1 deletion doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ The `os.getNetworkInterfaces()` method is deprecated. Please use the
<a id="DEP0024"></a>
### DEP0024: REPLServer.prototype.convertToContext()

Type: Runtime
Type: End-of-Life

The `REPLServer.prototype.convertToContext()` API is deprecated and should
not be used.
Expand Down
31 changes: 0 additions & 31 deletions lib/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -1223,37 +1223,6 @@ function regexpEscape(s) {
return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
}


/**
* Converts commands that use var and function <name>() to use the
* local exports.context when evaled. This provides a local context
* on the REPL.
*
* @param {String} cmd The cmd to convert.
* @return {String} The converted command.
*/
// TODO(princejwesley): Remove it prior to v8.0.0 release
// Reference: https://github.com/nodejs/node/pull/7829
REPLServer.prototype.convertToContext = util.deprecate(function(cmd) {
const scopeVar = /^\s*var\s*([\w$]+)(.*)$/m;
const scopeFunc = /^\s*function\s*([\w$]+)/;
var matches;

// Replaces: var foo = "bar"; with: self.context.foo = bar;
matches = scopeVar.exec(cmd);
if (matches && matches.length === 3) {
return 'self.context.' + matches[1] + matches[2];
}

// Replaces: function foo() {}; with: foo = function foo() {};
matches = scopeFunc.exec(this.bufferedCommand);
if (matches && matches.length === 2) {
return matches[1] + ' = ' + this.bufferedCommand;
}

return cmd;
}, 'replServer.convertToContext() is deprecated', 'DEP0024');

// If the error is that we've unexpectedly ended the input,
// then let the user try to recover by adding more input.
function isRecoverableError(e, code) {
Expand Down
18 changes: 0 additions & 18 deletions test/parallel/test-repl-deprecated.js

This file was deleted.

0 comments on commit 3d9e7bb

Please sign in to comment.