repl: deprecate REPLServer.prototype.memory
This method is only useful for the internal mechanics of the REPLServer and does not need to be exposed in user space. It was previously not documented, so I believe a Runtime deprecation makes sense. PR-URL: https://github.com/nodejs/node/pull/16242 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Jeremiah Senkpiel <fishrock123@rocketmail.com>
This commit is contained in:
parent
76abf0fae0
commit
7a29f44071
@ -728,6 +728,15 @@ Type: Runtime
|
|||||||
deprecated. Please use `fs.ftruncate()` or `fs.ftruncateSync()` to work with
|
deprecated. Please use `fs.ftruncate()` or `fs.ftruncateSync()` to work with
|
||||||
file descriptors.
|
file descriptors.
|
||||||
|
|
||||||
|
<a id="DEP0082"></a>
|
||||||
|
### DEP0082: 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.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size
|
||||||
[`Buffer.from(array)`]: buffer.html#buffer_class_method_buffer_from_array
|
[`Buffer.from(array)`]: buffer.html#buffer_class_method_buffer_from_array
|
||||||
|
14
lib/repl.js
14
lib/repl.js
@ -460,7 +460,7 @@ function REPLServer(prompt,
|
|||||||
self.line = prefix;
|
self.line = prefix;
|
||||||
self.cursor = prefix.length;
|
self.cursor = prefix.length;
|
||||||
}
|
}
|
||||||
self.memory(cmd);
|
_memory.call(self, cmd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -493,7 +493,7 @@ function REPLServer(prompt,
|
|||||||
|
|
||||||
function finish(e, ret) {
|
function finish(e, ret) {
|
||||||
debug('finish', e, ret);
|
debug('finish', e, ret);
|
||||||
self.memory(cmd);
|
_memory.call(self, cmd);
|
||||||
|
|
||||||
if (e && !self[kBufferedCommandSymbol] && cmd.trim().startsWith('npm ')) {
|
if (e && !self[kBufferedCommandSymbol] && cmd.trim().startsWith('npm ')) {
|
||||||
self.outputStream.write('npm should be run outside of the ' +
|
self.outputStream.write('npm should be run outside of the ' +
|
||||||
@ -1113,9 +1113,13 @@ REPLServer.prototype.defineCommand = function(keyword, cmd) {
|
|||||||
this.commands[keyword] = cmd;
|
this.commands[keyword] = cmd;
|
||||||
};
|
};
|
||||||
|
|
||||||
REPLServer.prototype.memory = function memory(cmd) {
|
REPLServer.prototype.memory = util.deprecate(
|
||||||
var self = this;
|
_memory,
|
||||||
|
'REPLServer.memory() is deprecated',
|
||||||
|
'DEP0082');
|
||||||
|
|
||||||
|
function _memory(cmd) {
|
||||||
|
const self = this;
|
||||||
self.lines = self.lines || [];
|
self.lines = self.lines || [];
|
||||||
self.lines.level = self.lines.level || [];
|
self.lines.level = self.lines.level || [];
|
||||||
|
|
||||||
@ -1185,7 +1189,7 @@ REPLServer.prototype.memory = function memory(cmd) {
|
|||||||
} else {
|
} else {
|
||||||
self.lines.level = [];
|
self.lines.level = [];
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
function addStandardGlobals(completionGroups, filter) {
|
function addStandardGlobals(completionGroups, filter) {
|
||||||
// Global object properties
|
// Global object properties
|
||||||
|
15
test/parallel/test-repl-memory-deprecation.js
Normal file
15
test/parallel/test-repl-memory-deprecation.js
Normal file
@ -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();
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user