| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e506bcd commit 766506a
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -653,6 +653,14 @@ Type: Runtime | |||
| 653 | 653 | The `REPLServer.bufferedCommand` property was deprecated in favor of | |
| 654 | 654 | [`REPLServer.clearBufferedCommand()`][]. | |
| 655 | 655 | ||
| 656 | + <a id="DEP0075"></a> | ||
| 657 | + ### DEP0075: REPLServer.parseREPLKeyword() | ||
| 658 | + | ||
| 659 | + Type: Runtime | ||
| 660 | + | ||
| 661 | + `REPLServer.parseREPLKeyword()` was removed from userland visibility. | ||
| 662 | + | ||
| 663 | + | ||
| 656 | 664 | [`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size | |
| 657 | 665 | [`Buffer.from(array)`]: buffer.html#buffer_class_method_buffer_from_array | |
| 658 | 666 | [`Buffer.from(buffer)`]: buffer.html#buffer_class_method_buffer_from_buffer | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -385,6 +385,20 @@ buffered but not yet executed. This method is primarily intended to be | |||
| 385 | 385 | called from within the action function for commands registered using the | |
| 386 | 386 | `replServer.defineCommand()` method. | |
| 387 | 387 | ||
| 388 | + ### replServer.parseREPLKeyword(keyword, [rest]) | ||
| 389 | + <!-- YAML | ||
| 390 | + added: v0.8.9 | ||
| 391 | + deprecated: REPLACEME | ||
| 392 | + --> | ||
| 393 | + | ||
| 394 | + * `keyword` {string} the potential keyword to parse and execute | ||
| 395 | + * `rest` {any} any parameters to the keyword command | ||
| 396 | + | ||
| 397 | + > Stability: 0 - Deprecated. | ||
| 398 | + | ||
| 399 | + An internal method used to parse and execute `REPLServer` keywords. | ||
| 400 | + Returns `true` if `keyword` is a valid keyword, otherwise `false`. | ||
| 401 | + | ||
| 388 | 402 | ## repl.start([options]) | |
| 389 | 403 | <!-- YAML | |
| 390 | 404 | added: v0.1.91 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -374,6 +374,20 @@ function REPLServer(prompt, | |||
| 374 | 374 | }; | |
| 375 | 375 | } | |
| 376 | 376 | ||
| 377 | + function _parseREPLKeyword(keyword, rest) { | ||
| 378 | + var cmd = this.commands[keyword]; | ||
| 379 | + if (cmd) { | ||
| 380 | + cmd.action.call(this, rest); | ||
| 381 | + return true; | ||
| 382 | + } | ||
| 383 | + return false; | ||
| 384 | + } | ||
| 385 | + | ||
| 386 | + self.parseREPLKeyword = util.deprecate( | ||
| 387 | + _parseREPLKeyword, | ||
| 388 | + 'REPLServer.parseREPLKeyword() is deprecated', | ||
| 389 | + 'DEP0075'); | ||
| 390 | + | ||
| 377 | 391 | self.on('close', function emitExit() { | |
| 378 | 392 | self.emit('exit'); | |
| 379 | 393 | }); | |
@@ -434,7 +448,7 @@ function REPLServer(prompt, | |||
| 434 | 448 | const matches = trimmedCmd.match(/^\.([^\s]+)\s*(.*)$/); | |
| 435 | 449 | const keyword = matches && matches[1]; | |
| 436 | 450 | const rest = matches && matches[2]; | |
| 437 | - if (self.parseREPLKeyword(keyword, rest) === true) { | ||
| 451 | + if (_parseREPLKeyword.call(self, keyword, rest) === true) { | ||
| 438 | 452 | return; | |
| 439 | 453 | } | |
| 440 | 454 | if (!self[kBufferedCommandSymbol]) { | |
@@ -1064,22 +1078,6 @@ REPLServer.prototype.completeOnEditorMode = (callback) => (err, results) => { | |||
| 1064 | 1078 | callback(null, [[`${completeOn}${longestCommonPrefix(data)}`], completeOn]); | |
| 1065 | 1079 | }; | |
| 1066 | 1080 | ||
| 1067 | - /** | ||
| 1068 | - * Used to parse and execute the Node REPL commands. | ||
| 1069 | - * | ||
| 1070 | - * @param {keyword} keyword The command entered to check. | ||
| 1071 | - * @return {Boolean} If true it means don't continue parsing the command. | ||
| 1072 | - */ | ||
| 1073 | - REPLServer.prototype.parseREPLKeyword = function(keyword, rest) { | ||
| 1074 | - var cmd = this.commands[keyword]; | ||
| 1075 | - if (cmd) { | ||
| 1076 | - cmd.action.call(this, rest); | ||
| 1077 | - return true; | ||
| 1078 | - } | ||
| 1079 | - return false; | ||
| 1080 | - }; | ||
| 1081 | - | ||
| 1082 | - | ||
| 1083 | 1081 | REPLServer.prototype.defineCommand = function(keyword, cmd) { | |
| 1084 | 1082 | if (typeof cmd === 'function') { | |
| 1085 | 1083 | cmd = { action: cmd }; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,16 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const assert = require('assert'); | ||
| 4 | + const repl = require('repl'); | ||
| 5 | + | ||
| 6 | + testParseREPLKeyword(); | ||
| 7 | + | ||
| 8 | + function testParseREPLKeyword() { | ||
| 9 | + const server = repl.start({ prompt: '> ' }); | ||
| 10 | + const warn = 'REPLServer.parseREPLKeyword() is deprecated'; | ||
| 11 | + | ||
| 12 | + common.expectWarning('DeprecationWarning', warn); | ||
| 13 | + assert.ok(server.parseREPLKeyword('clear')); | ||
| 14 | + assert.ok(!server.parseREPLKeyword('tacos')); | ||
| 15 | + server.close(); | ||
| 16 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments