Skip to content

Commit 2ec1573

Browse files
committed
fix: apply review comments
Signed-off-by: Snehil Shah <[email protected]> --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: passed - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent cce54d7 commit 2ec1573

File tree

12 files changed

+88
-42
lines changed

12 files changed

+88
-42
lines changed

lib/node_modules/@stdlib/repl/base/ctor/lib/completer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function completer( repl ) {
8484
return complete;
8585

8686
/**
87-
* Callback invoked upon a user entering the TAB character at the command prompt.
87+
* Generates completions for a given line.
8888
*
8989
* @private
9090
* @param {string} line - current line

lib/node_modules/@stdlib/repl/base/ctor/lib/is_multiline_input.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function isMultilineInput( input ) {
6464
return false;
6565
}
6666
// Check if the command has valid syntax...
67-
tmp = this._processCommand( input );
67+
tmp = this.processCommand( input );
6868
if ( !( tmp instanceof Error ) ) {
6969
debug( 'Multi-line input not detected.' );
7070
return false;

lib/node_modules/@stdlib/repl/base/ctor/lib/main.js

Lines changed: 68 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ var debug = logger( 'repl' );
7070
* @returns {REPL} REPL instance
7171
*
7272
* @example
73-
* var REPL = require( '@stdlib/repl/base' );
74-
*
7573
* // Create a new REPL:
7674
* var repl = new REPL();
7775
*
@@ -189,11 +187,8 @@ function REPL( options ) {
189187
// Create a REPL execution context:
190188
setNonEnumerable( this, '_context', this.createContext() );
191189

192-
// Create a new TAB completer:
193-
setNonEnumerableReadOnly( this, '_completer', completerFactory( this ) );
194-
195-
// Create a new tokenizer:
196-
setNonEnumerableReadOnly( this, '_tokenizer', tokenizer );
190+
// Create a new completer:
191+
setNonEnumerableReadOnly( this, 'completer', completerFactory( this ) );
197192

198193
// Add listener for "command" events:
199194
this.on( 'command', onCommand );
@@ -269,38 +264,95 @@ inherit( REPL, EventEmitter );
269264
/**
270265
* Checks if the given input is a possible multi-line command.
271266
*
272-
* @private
273-
* @name _isMultilineInput
267+
* @name isMultilineInput
274268
* @memberof REPL.prototype
275269
* @type {Function}
276270
* @param {string} input - input command
277271
* @returns {boolean} boolean indicating whether the given input is a possible multi-line command
272+
*
273+
* @example
274+
* // Create a new REPL:
275+
* var repl = new REPL();
276+
*
277+
* // Check if an input is a possible multi-line command:
278+
* var input = 'for( var i = 0; i < 10; i++ ) {';
279+
* var out = repl.isMultilineInput( input );
280+
*
281+
* // Close the REPL:
282+
* repl.close();
278283
*/
279-
setNonEnumerableReadOnly( REPL.prototype, '_isMultilineInput', isMultilineInput );
284+
setNonEnumerableReadOnly( REPL.prototype, 'isMultilineInput', isMultilineInput );
280285

281286
/**
282-
* Processes a "raw" input command..
287+
* Processes a "raw" input command.
283288
*
284-
* @private
285-
* @name _processCommand
289+
* @name processCommand
286290
* @memberof REPL.prototype
287291
* @type {Function}
288292
* @param {string} code - unevaluated command
289293
* @returns {(string|Error)} processed command or an error
294+
*
295+
* @example
296+
* // Create a new REPL:
297+
* var repl = new REPL();
298+
*
299+
* // Process raw command:
300+
* var code = 'var y = 10;';
301+
* var out = repl.processCommand( code );
302+
*
303+
* // Close the REPL:
304+
* repl.close();
290305
*/
291-
setNonEnumerableReadOnly( REPL.prototype, '_processCommand', processCommand );
306+
setNonEnumerableReadOnly( REPL.prototype, 'processCommand', processCommand );
292307

293308
/**
294309
* Compiles a command.
295310
*
296311
* @private
297-
* @name _compileCommand
312+
* @name compileCommand
298313
* @memberof REPL.prototype
299314
* @type {Function}
300315
* @param {string} cmd - command string
301316
* @returns {(Object|Error)} compiled command or an error
317+
*
318+
* @example
319+
* // Create a new REPL:
320+
* var repl = new REPL();
321+
*
322+
* // Process raw command:
323+
* var code = 'var y = 10;';
324+
* var cmd = repl.processCommand( code );
325+
*
326+
* // Compile processed command:
327+
* var out = repl.compileCommand( cmd );
328+
*
329+
* // Close the REPL:
330+
* repl.close();
331+
*/
332+
setNonEnumerableReadOnly( REPL.prototype, 'compileCommand', compileCommand );
333+
334+
/**
335+
* Tokenizes the input line based on ECMAScript specification.
336+
*
337+
* @name tokenizer
338+
* @memberof REPL.prototype
339+
* @type {Function}
340+
* @param {string} line - input line
341+
* @param {Object} context - REPL context
342+
* @returns {Array} array of tokens
343+
*
344+
* @example
345+
* // Create a new REPL:
346+
* var repl = new REPL();
347+
*
348+
* // Tokenize an input line:
349+
* var line = 'var x = 5;';
350+
* var out = repl.tokenizer( line, {} );
351+
*
352+
* // Close the REPL:
353+
* repl.close();
302354
*/
303-
setNonEnumerableReadOnly( REPL.prototype, '_compileCommand', compileCommand );
355+
setNonEnumerableReadOnly( REPL.prototype, 'tokenizer', tokenizer );
304356

305357
/**
306358
* Creates a REPL context.

lib/node_modules/@stdlib/repl/base/ctor/lib/process_input.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function processInput( repl, input ) {
5757
} else {
5858
// Check if the command has valid syntax...
5959
debug( 'Processing command...' );
60-
tmp = repl._processCommand( input );
60+
tmp = repl.processCommand( input );
6161
if ( tmp instanceof Error ) {
6262
repl.emit( 'command', input, false, tmp, false ); // command failed
6363
return;
@@ -67,7 +67,7 @@ function processInput( repl, input ) {
6767

6868
// Attempt to compile the command:
6969
debug( 'Attempting to compile command...' );
70-
code = repl._compileCommand( tmp );
70+
code = repl.compileCommand( tmp );
7171
if ( code instanceof Error ) {
7272
debug( 'Error: %s', code.message );
7373
repl.emit( 'command', input, false, code, false ); // command failed

lib/node_modules/@stdlib/repl/base/ctor/lib/validate.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ var format = require( '@stdlib/string/format' );
3838
* @private
3939
* @param {Object} opts - destination object
4040
* @param {Options} options - function options
41-
* @param {ReadableStream} [options.input=process.stdin] - input stream
42-
* @param {WritableStream} [options.output=process.stdout] - output stream
43-
* @param {WritableStream} [options.error=process.stderr] - error stream
44-
* @param {boolean} [options.sandbox=true] - boolean indicating whether to run a REPL in a sandboxed context
45-
* @param {PositiveInteger} [options.timeout=4294967295] - number of milliseconds to execute a command before terminating execution
41+
* @param {ReadableStream} [options.input] - input stream
42+
* @param {WritableStream} [options.output] - output stream
43+
* @param {WritableStream} [options.error] - error stream
44+
* @param {boolean} [options.sandbox] - boolean indicating whether to run a REPL in a sandboxed context
45+
* @param {PositiveInteger} [options.timeout] - number of milliseconds to execute a command before terminating execution
4646
* @param {string} [options.save] - file path specifying where to save REPL command history
4747
* @param {string} [options.log] - file path specifying where to save REPL commands and printed output
48-
* @param {string} [options.quiet=false] - boolean indicating whether log information, confirmation messages, and other possible REPL diagnostics should be silenced
48+
* @param {string} [options.quiet] - boolean indicating whether log information, confirmation messages, and other possible REPL diagnostics should be silenced
4949
* @returns {(Error|null)} error or null
5050
*
5151
* @example

lib/node_modules/@stdlib/repl/base/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@
5555
"interactive",
5656
"console",
5757
"terminal",
58-
"shell",
59-
"server",
60-
"toplevel"
58+
"shell"
6159
]
6260
}

lib/node_modules/@stdlib/repl/cli/lib/commands/example.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ function command( repl, cmds ) {
162162
lines.push( out[ i ] );
163163

164164
// If line is part of a multi-line input, wait for the next line...
165-
if ( repl._isMultilineInput( lines.join( '\n' ) ) ) {
165+
if ( repl.isMultilineInput( lines.join( '\n' ) ) ) {
166166
return next();
167167
}
168168
for ( j = 0; j < lines.length; j++ ) {

lib/node_modules/@stdlib/repl/cli/lib/eager_evaluator.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,13 +299,13 @@ setNonEnumerableReadOnly( EagerEvaluator.prototype, 'onKeypress', function onKey
299299
return;
300300
}
301301
debug( 'Processing command...' );
302-
tmp = this._repl._processCommand( code );
302+
tmp = this._repl.processCommand( code );
303303
if ( tmp instanceof Error ) {
304304
debug( 'Error encountered when processing command: %s', tmp.message );
305305
return;
306306
}
307307
debug( 'Compiling command...' );
308-
executable = this._repl._compileCommand( tmp );
308+
executable = this._repl.compileCommand( tmp );
309309
if ( executable instanceof Error ) {
310310
debug( 'Error encountered when compiling command: %s', executable.message );
311311
return;

lib/node_modules/@stdlib/repl/cli/lib/main.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,13 +230,13 @@ function REPL( options ) {
230230
setNonEnumerableReadOnly( this, '_editorActions', new EditorActions( this, this._rli._ttyWrite ) );
231231

232232
// Create a new TAB completer engine:
233-
setNonEnumerableReadOnly( this, '_completerEngine', new CompleterEngine( this, this._completer, this._wstream, this._rli._ttyWrite ) );
233+
setNonEnumerableReadOnly( this, '_completerEngine', new CompleterEngine( this, this.completer, this._wstream, this._rli._ttyWrite ) );
234234

235235
// Create a new auto-closer:
236236
setNonEnumerableReadOnly( this, '_autoCloser', new AutoCloser( this._rli, this._settings.autoClosePairs, this._settings.autoDeletePairs, this._multilineHandler ) );
237237

238238
// Initialize a preview completer:
239-
setNonEnumerableReadOnly( this, '_previewCompleter', new PreviewCompleter( this._rli, this._completer, this._ostream, this._settings.completionPreviews ) );
239+
setNonEnumerableReadOnly( this, '_previewCompleter', new PreviewCompleter( this._rli, this.completer, this._ostream, this._settings.completionPreviews ) );
240240

241241
// Initialize a syntax-highlighter:
242242
setNonEnumerableReadOnly( this, '_syntaxHighlighter', new SyntaxHighlighter( this, this._ostream, this._settings.syntaxHighlighting ) );
@@ -464,7 +464,7 @@ function REPL( options ) {
464464
if ( success === false ) {
465465
self._ostream.write( 'Error: '+res.message+'\n' );
466466
} else if ( !silent && res !== void 0 ) {
467-
pre = replace( self._outputPrompt, '%d', (self._count).toString() );
467+
pre = replace( self._outputPrompt, '%d', self._count.toString() );
468468

469469
if ( isndarrayLike( res ) ) {
470470
tmp = res.toString(); // FIXME: this is a hack in order to avoid printing private ndarray properties in the REPL, as done by the built-in `util.inspect`. Ideally, we'd roll our own inspector which specifically accommodates stdlib's ndarray and other specialized classes.
@@ -675,7 +675,6 @@ setNonEnumerableReadOnly( REPL.prototype, 'createContext', function createContex
675675
var context;
676676
var cmds;
677677

678-
// TODO: Call parent method
679678
context = BaseREPL.prototype.createContext.call( this );
680679

681680
// Get the list of REPL-specific commands:

lib/node_modules/@stdlib/repl/cli/lib/multiline_handler.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,6 @@ function MultilineHandler( repl, ttyWrite ) {
6868
// Cache a reference to the command array:
6969
this._cmd = repl._cmd;
7070

71-
// Cache a reference to the command queue:
72-
this._queue = repl._queue;
73-
7471
// Initialize an internal object for command history:
7572
this._history = {};
7673
this._history.list = repl._history;
@@ -631,7 +628,7 @@ setNonEnumerableReadOnly( MultilineHandler.prototype, 'beforeKeypress', function
631628
this._lines[ this._lineIndex ] = this._rli.line;
632629

633630
// If we are in paste mode or the command is incomplete, trigger multi-line mode...
634-
if ( !this._multiline.pasteMode && !this._repl._isMultilineInput( cmd.join( '\n' ) ) ) {
631+
if ( !this._multiline.pasteMode && !this._repl.isMultilineInput( cmd.join( '\n' ) ) ) {
635632
this._ttyWrite.call( this._rli, data, key );
636633
return;
637634
}

0 commit comments

Comments
 (0)