Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repl: remove unused function convertToContext #13434

Merged
merged 1 commit into from
Jun 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.