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: deprecate REPLServer.prototype.memory #16242

Closed
wants to merge 1 commit into from
Closed
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
9 changes: 9 additions & 0 deletions doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,15 @@ Type: Runtime
deprecated. Please use `fs.ftruncate()` or `fs.ftruncateSync()` to work with
file descriptors.

<a id="DEP00XX"></a>
### DEP00XX: REPLServer.prototype.memory()

Type: Runtime

`REPLServer.prototype.memory()` is a function only necessary for the
internal mechanics of the `REPLServer` itself, and is therefore not
necessary in user space.


[`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size
[`Buffer.from(array)`]: buffer.html#buffer_class_method_buffer_from_array
Expand Down
14 changes: 9 additions & 5 deletions lib/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ function REPLServer(prompt,
self.line = prefix;
self.cursor = prefix.length;
}
self.memory(cmd);
_memory.call(self, cmd);
return;
}

Expand Down Expand Up @@ -493,7 +493,7 @@ function REPLServer(prompt,

function finish(e, ret) {
debug('finish', e, ret);
self.memory(cmd);
_memory.call(self, cmd);

if (e && !self[kBufferedCommandSymbol] && cmd.trim().startsWith('npm ')) {
self.outputStream.write('npm should be run outside of the ' +
Expand Down Expand Up @@ -1113,9 +1113,13 @@ REPLServer.prototype.defineCommand = function(keyword, cmd) {
this.commands[keyword] = cmd;
};

REPLServer.prototype.memory = function memory(cmd) {
var self = this;
REPLServer.prototype.memory = util.deprecate(
_memory,
'REPLServer.memory() is deprecated',
'DEP00XX');

function _memory(cmd) {
const self = this;
self.lines = self.lines || [];
self.lines.level = self.lines.level || [];

Expand Down Expand Up @@ -1185,7 +1189,7 @@ REPLServer.prototype.memory = function memory(cmd) {
} else {
self.lines.level = [];
}
};
}

function addStandardGlobals(completionGroups, filter) {
// Global object properties
Expand Down
15 changes: 15 additions & 0 deletions test/parallel/test-repl-memory-deprecation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const repl = require('repl');

testMemory();

function testMemory() {
const server = repl.start({ prompt: '> ' });
const warn = 'REPLServer.memory() is deprecated';

common.expectWarning('DeprecationWarning', warn);
assert.strictEqual(server.memory(), undefined);
server.close();
}