Skip to content

Commit 7a29f44

Browse files
committed
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: #16242 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Jeremiah Senkpiel <[email protected]>
1 parent 76abf0f commit 7a29f44

File tree

3 files changed

+33
-5
lines changed

3 files changed

+33
-5
lines changed

doc/api/deprecations.md

+9
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,15 @@ Type: Runtime
728728
deprecated. Please use `fs.ftruncate()` or `fs.ftruncateSync()` to work with
729729
file descriptors.
730730
731+
<a id="DEP0082"></a>
732+
### DEP0082: REPLServer.prototype.memory()
733+
734+
Type: Runtime
735+
736+
`REPLServer.prototype.memory()` is a function only necessary for the
737+
internal mechanics of the `REPLServer` itself, and is therefore not
738+
necessary in user space.
739+
731740
732741
[`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size
733742
[`Buffer.from(array)`]: buffer.html#buffer_class_method_buffer_from_array

lib/repl.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ function REPLServer(prompt,
460460
self.line = prefix;
461461
self.cursor = prefix.length;
462462
}
463-
self.memory(cmd);
463+
_memory.call(self, cmd);
464464
return;
465465
}
466466

@@ -493,7 +493,7 @@ function REPLServer(prompt,
493493

494494
function finish(e, ret) {
495495
debug('finish', e, ret);
496-
self.memory(cmd);
496+
_memory.call(self, cmd);
497497

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

1116-
REPLServer.prototype.memory = function memory(cmd) {
1117-
var self = this;
1116+
REPLServer.prototype.memory = util.deprecate(
1117+
_memory,
1118+
'REPLServer.memory() is deprecated',
1119+
'DEP0082');
11181120

1121+
function _memory(cmd) {
1122+
const self = this;
11191123
self.lines = self.lines || [];
11201124
self.lines.level = self.lines.level || [];
11211125

@@ -1185,7 +1189,7 @@ REPLServer.prototype.memory = function memory(cmd) {
11851189
} else {
11861190
self.lines.level = [];
11871191
}
1188-
};
1192+
}
11891193

11901194
function addStandardGlobals(completionGroups, filter) {
11911195
// Global object properties
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
const common = require('../common');
3+
const assert = require('assert');
4+
const repl = require('repl');
5+
6+
testMemory();
7+
8+
function testMemory() {
9+
const server = repl.start({ prompt: '> ' });
10+
const warn = 'REPLServer.memory() is deprecated';
11+
12+
common.expectWarning('DeprecationWarning', warn);
13+
assert.strictEqual(server.memory(), undefined);
14+
server.close();
15+
}

0 commit comments

Comments
 (0)