From 2ca9f94e3323177b06b910aa1ac3ba439bb66561 Mon Sep 17 00:00:00 2001 From: Lance Ball Date: Wed, 14 Jun 2017 15:52:15 -0400 Subject: [PATCH] repl: make REPLServer.bufferedCommand private The `REPLServer.bufferedCommand` property was undocumented, except for its usage appearing, unexplained, in an example for `REPLServer.defineCommand`. This commit deprecates that property, privatizes it, and adds a `REPLServer.clearBufferedCommand()` function that will clear the buffer. PR-URL: https://github.com/nodejs/node/pull/13687 Reviewed-By: Colin Ihrig Reviewed-By: Daniel Bevenius Reviewed-By: James Snell Reviewed-By: Michael Dawson Reviewed-By: Ruben Bridgewater Refs: https://github.com/nodejs/node/issues/12686 --- doc/api/deprecations.md | 9 ++++++++ doc/api/repl.md | 12 +++++++++- lib/repl.js | 49 +++++++++++++++++++++++++++-------------- 3 files changed, 52 insertions(+), 18 deletions(-) diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index 64baf58867b..5f07fa6f7aa 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -645,6 +645,14 @@ with inappropriate names has been deprecated. *Note*: As the original API was undocumented and not generally useful for non-internal code, no replacement API is provided. + +### DEP0074: REPLServer.bufferedCommand + +Type: Runtime + +The `REPLServer.bufferedCommand` property was deprecated in favor of +[`REPLServer.clearBufferedCommand()`][]. + [`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size [`Buffer.from(array)`]: buffer.html#buffer_class_method_buffer_from_array [`Buffer.from(buffer)`]: buffer.html#buffer_class_method_buffer_from_buffer @@ -708,3 +716,4 @@ non-internal code, no replacement API is provided. [alloc_unsafe_size]: buffer.html#buffer_class_method_buffer_allocunsafe_size [from_arraybuffer]: buffer.html#buffer_class_method_buffer_from_arraybuffer_byteoffset_length [from_string_encoding]: buffer.html#buffer_class_method_buffer_from_string_encoding +[`REPLServer.clearBufferedCommand()`]: repl.html#repl_replserver_clearbufferedcommand diff --git a/doc/api/repl.md b/doc/api/repl.md index f276b965bdf..7a9c1f81e56 100644 --- a/doc/api/repl.md +++ b/doc/api/repl.md @@ -335,7 +335,7 @@ const replServer = repl.start({ prompt: '> ' }); replServer.defineCommand('sayhello', { help: 'Say hello', action(name) { - this.bufferedCommand = ''; + this.clearBufferedCommand(); console.log(`Hello, ${name}!`); this.displayPrompt(); } @@ -375,6 +375,16 @@ The `replServer.displayPrompt` method is primarily intended to be called from within the action function for commands registered using the `replServer.defineCommand()` method. +### replServer.clearBufferedCommand() + + +The `replServer.clearBufferedComand()` method clears any command that has been +buffered but not yet executed. This method is primarily intended to be +called from within the action function for commands registered using the +`replServer.defineCommand()` method. + ## repl.start([options])