Skip to content

Commit 4b51d4a

Browse files
committed
Replace deprecated REPL implementation
1 parent af0940a commit 4b51d4a

File tree

3 files changed

+57
-41
lines changed

3 files changed

+57
-41
lines changed

lib/node_modules/@stdlib/repl/README.md

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
@license Apache-2.0
44
5-
Copyright (c) 2018 The Stdlib Authors.
5+
Copyright (c) 2019 The Stdlib Authors.
66
77
Licensed under the Apache License, Version 2.0 (the "License");
88
you may not use this file except in compliance with the License.
@@ -20,7 +20,7 @@ limitations under the License.
2020

2121
# REPL
2222

23-
> REPL environment.
23+
> [REPL][@stdlib/repl/ctor] environment.
2424
2525
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
2626

@@ -37,23 +37,21 @@ limitations under the License.
3737
## Usage
3838

3939
```javascript
40-
var repl = require( '@stdlib/repl' );
40+
var REPL = require( '@stdlib/repl' );
4141
```
4242

43-
#### repl( \[options], clbk )
43+
#### REPL( \[options] )
4444

45-
Starts a REPL environment.
46-
47-
<!-- run-disable -->
45+
Returns a [`REPL`][@stdlib/repl/ctor] instance.
4846

4947
```javascript
50-
repl( onStart );
48+
// Create a new REPL:
49+
var repl = new REPL();
5150

52-
function onStart( error, r ) {
53-
if ( error ) {
54-
throw error;
55-
}
56-
}
51+
// ...
52+
53+
// Close the REPL:
54+
repl.close();
5755
```
5856

5957
</section>
@@ -77,21 +75,22 @@ function onStart( error, r ) {
7775
<!-- eslint no-undef: "error" -->
7876

7977
```javascript
80-
var repl = require( '@stdlib/repl' );
78+
var REPL = require( '@stdlib/repl' );
8179

82-
// Start the REPL:
83-
repl( onStart );
80+
function onExit() {
81+
console.log( '' );
82+
console.log( 'REPL closed.' );
83+
}
84+
85+
// Create a new REPL:
86+
var repl = new REPL();
87+
repl.on( 'exit', onExit );
8488

85-
function onStart( error, r ) {
86-
if ( error ) {
87-
throw error;
88-
}
89-
// After the REPL has started, exit the process...
90-
setTimeout( onTimeout, 2500 );
89+
setTimeout( onTimeout, 1000 );
9190

92-
function onTimeout() {
93-
r.close();
94-
}
91+
function onTimeout() {
92+
// Close the REPL:
93+
repl.close();
9594
}
9695
```
9796

@@ -114,8 +113,17 @@ Usage: stdlib-repl [options]
114113
115114
Options:
116115
117-
-h, --help Print this message.
118-
-V, --version Print the package version.
116+
-h, --help Print this message.
117+
-V, --version Print the package version.
118+
--welcome <message> Welcome message.
119+
--input_prompt <prompt> Input prompt. Default: 'In [%d]: '.
120+
--output_prompt <prompt> Output prompt. Default: 'Out[%d]: '.
121+
--padding <padding> Empty lines between commands. Default: 1.
122+
--load <filepath> JavaScript file to evaluate line-by-line.
123+
--save <filepath> File to save REPL command history.
124+
--logfile <filepath> File to log REPL commands and printed output.
125+
--timeout <timeout> Milliseconds before terminating a command.
126+
--quiet Disable printing of REPL logs and diagnostics.
119127
```
120128

121129
</section>
@@ -128,7 +136,6 @@ Options:
128136

129137
```bash
130138
$ stdlib-repl
131-
Starting REPL...
132139
```
133140

134141
</section>
@@ -151,6 +158,8 @@ Starting REPL...
151158

152159
<section class="links">
153160

161+
[@stdlib/repl/ctor]: https://github.com/stdlib-js/stdlib
162+
154163
</section>
155164

156165
<!-- /.links -->

lib/node_modules/@stdlib/repl/lib/index.js

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2018 The Stdlib Authors.
4+
* Copyright (c) 2019 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -24,21 +24,28 @@
2424
* @module @stdlib/repl
2525
*
2626
* @example
27-
* var repl = require( '@stdlib/repl' );
27+
* var debug = require( '@stdlib/streams/node/debug-sink' );
28+
* var REPL = require( '@stdlib/repl' );
2829
*
29-
* repl( onStart );
30-
*
31-
* function onStart( error, r ) {
32-
* if ( error ) {
33-
* throw error;
34-
* }
35-
* r.close();
30+
* function onExit() {
31+
* console.log( 'REPL closed.' );
3632
* }
33+
*
34+
* // Create a new REPL:
35+
* var repl = new REPL({
36+
* 'output': debug()
37+
* });
38+
* repl.on( 'exit', onExit );
39+
*
40+
* // ...
41+
*
42+
* // Close the REPL:
43+
* repl.close();
3744
*/
3845

3946
// MODULES //
4047

41-
var repl = require( '@stdlib/repl/server' );
48+
var repl = require( '@stdlib/repl/ctor' );
4249

4350

4451
// EXPORTS //

lib/node_modules/@stdlib/repl/test/test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
var tape = require( 'tape' );
2424
var IS_NODE = require( '@stdlib/assert/is-node' );
25-
var server = require( '@stdlib/repl/server' );
25+
var REPL = require( '@stdlib/repl/ctor' );
2626
var repl = require( './../lib' );
2727

2828

@@ -34,9 +34,9 @@ tape( 'main export is a function', function test( t ) {
3434
t.end();
3535
});
3636

37-
tape( 'if the environment is Node.js, the export is an alias for creating a REPL server', function test( t ) {
37+
tape( 'if the environment is Node.js, the export is an alias for creating a REPL instance', function test( t ) {
3838
if ( IS_NODE ) {
39-
t.strictEqual( repl, server, 'is alias' );
39+
t.strictEqual( repl, REPL, 'is alias' );
4040
}
4141
t.end();
4242
});

0 commit comments

Comments
 (0)