Skip to content

Commit b7b5082

Browse files
committed
refactor: move base implementation to ctor package
Signed-off-by: Snehil Shah <snehilshah.989@gmail.com> --- 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: passed - 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: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - 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 fdbd335 commit b7b5082

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+518
-252
lines changed

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

Lines changed: 16 additions & 198 deletions
Original file line numberDiff line numberDiff line change
@@ -18,236 +18,56 @@ limitations under the License.
1818
1919
-->
2020

21-
# REPL
21+
# Base
2222

23-
> Base class for Read-Eval-Print Loop (REPL) environment.
24-
25-
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
26-
27-
<section class="intro">
28-
29-
A Read-Eval-Print Loop (REPL) environment is an interactive programming environment which takes individual user inputs (e.g., single expressions), evaluates those inputs, and returns the result. Accordingly, a program written in a REPL environment is executed piecewise and sequentially.
30-
31-
REPL environments find common use in exploratory programming, prototyping, and debugging.
32-
33-
The REPL environment exposed here is available both as a standalone application and as a library which is embeddable in other libraries and applications.
34-
35-
</section>
36-
37-
<!-- /.intro -->
38-
39-
<!-- Package usage documentation. -->
23+
> Base REPL functionality.
4024
4125
<section class="usage">
4226

4327
## Usage
4428

4529
```javascript
46-
var REPL = require( '@stdlib/repl/base' );
30+
var ns = require( '@stdlib/repl/base' );
4731
```
4832

49-
#### REPL( \[options] )
33+
#### ns
5034

51-
Returns a `REPL` instance.
35+
Namespace containing "base" (i.e., lower-level) REPL functionality.
5236

5337
```javascript
54-
// Create a new REPL:
55-
var repl = new REPL();
56-
57-
// ...
58-
59-
// Execute a command:
60-
repl.emit( 'input', '2 + 3' );
61-
62-
// ...
63-
64-
// Close the REPL:
65-
repl.close();
38+
var o = ns;
39+
// returns {...}
6640
```
6741

68-
The function accepts the following `options`:
69-
70-
- **input**: input (readable) stream. Default: [`stdin`][@stdlib/streams/node/stdin].
71-
- **output**: output (writable) stream. Default: [`stdout`][@stdlib/streams/node/stdout].
72-
- **error**: error (writable) stream. Default: [`stderr`][@stdlib/streams/node/stderr].
73-
- **sandbox**: boolean indicating whether to run a REPL in a sandboxed context. Default: `false`.
74-
- **timeout**: number of milliseconds to execute a command before terminating execution. Default: `4294967295`.
75-
- **save**: file path specifying where to save REPL command history.
76-
- **log**: file path specifying where to save REPL commands and printed output.
77-
- **quiet**: boolean indicating whether log information, confirmation messages, and other possible REPL diagnostics should be silenced. Default: `false`.
42+
<!-- <toc pattern="*"> -->
7843

79-
#### REPL.prototype.createContext()
80-
81-
Returns a REPL context.
82-
83-
```javascript
84-
// Create a new REPL:
85-
var repl = new REPL();
86-
87-
// ...
88-
89-
// Return a new REPL context:
90-
var ctx = repl.createContext();
91-
92-
// ...
93-
94-
// Close the REPL:
95-
repl.close();
96-
```
44+
<div class="namespace-toc">
9745

98-
#### REPL.prototype.resetContext()
99-
100-
Resets a REPL's execution context.
101-
102-
```javascript
103-
// Create a new REPL:
104-
var repl = new REPL();
105-
106-
// ...
107-
108-
// Reset the REPL context:
109-
repl.resetContext();
110-
111-
// ...
112-
113-
// Close the REPL:
114-
repl.close();
115-
```
116-
117-
#### REPL.prototype.clearHistory()
118-
119-
Clears a REPL's history.
120-
121-
```javascript
122-
// Create a new REPL:
123-
var repl = new REPL();
124-
125-
// ...
126-
127-
// Clear the REPL history:
128-
repl.clearHistory();
129-
130-
// ...
131-
132-
// Close the REPL:
133-
repl.close();
134-
```
135-
136-
#### REPL.prototype.clearUserDocs()
137-
138-
Clears user-defined documentation.
139-
140-
```javascript
141-
// Create a new REPL:
142-
var repl = new REPL();
46+
</div>
14347

144-
// ...
145-
146-
// Clear user-defined documentation:
147-
repl.clearUserDocs();
148-
149-
// ...
150-
151-
// Close the REPL:
152-
repl.close();
153-
```
154-
155-
#### REPL.prototype.reset()
156-
157-
Resets a REPL.
158-
159-
```javascript
160-
// Create a new REPL:
161-
var repl = new REPL();
162-
163-
// ...
164-
165-
// Reset the REPL:
166-
repl.reset();
167-
168-
// ...
169-
170-
// Close the REPL:
171-
repl.close();
172-
```
173-
174-
#### REPL.prototype.close()
175-
176-
Closes a REPL.
177-
178-
```javascript
179-
// Create a new REPL:
180-
var repl = new REPL();
181-
182-
// ...
183-
184-
// Close the REPL:
185-
repl.close();
186-
```
187-
188-
* * *
48+
<!-- </toc> -->
18949

19050
</section>
19151

19252
<!-- /.usage -->
19353

194-
<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
195-
196-
<section class="notes">
197-
198-
</section>
199-
200-
<!-- /.notes -->
201-
202-
<!-- Package usage examples. -->
203-
204-
* * *
205-
20654
<section class="examples">
20755

20856
## Examples
20957

21058
<!-- eslint no-undef: "error" -->
21159

21260
```javascript
213-
var REPL = require( '@stdlib/repl/base' );
214-
215-
function onCommand( cmd, success, res ) {
216-
console.log( cmd + ' = ' + res.toString() );
217-
}
218-
219-
// Create a new REPL:
220-
var repl = new REPL();
221-
repl.on( 'command', onCommand );
61+
var objectKeys = require( '@stdlib/utils/keys' );
62+
var ns = require( '@stdlib/repl/base' );
22263

223-
// Execute a command:
224-
repl.emit( 'input', '3 + 2' );
225-
226-
// Close the REPL:
227-
repl.close();
228-
console.log( 'REPL closed.' );
64+
console.log( objectKeys( ns ) );
22965
```
23066

23167
</section>
23268

23369
<!-- /.examples -->
23470

235-
* * *
236-
237-
<section class="notes">
238-
239-
</section>
240-
241-
<!-- /.notes -->
242-
243-
<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
244-
245-
<section class="references">
246-
247-
</section>
248-
249-
<!-- /.references -->
250-
25171
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
25272

25373
<section class="related">
@@ -260,11 +80,9 @@ console.log( 'REPL closed.' );
26080

26181
<section class="links">
26282

263-
[@stdlib/streams/node/stdin]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/stdin
264-
265-
[@stdlib/streams/node/stdout]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/stdout
83+
<!-- <toc-links> -->
26684

267-
[@stdlib/streams/node/stderr]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/streams/node/stderr
85+
<!-- </toc-links> -->
26886

26987
</section>
27088

0 commit comments

Comments
 (0)