You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -18,236 +18,56 @@ limitations under the License.
18
18
19
19
-->
20
20
21
-
# REPL
21
+
# Base
22
22
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
-
<sectionclass="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.
-**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="*"> -->
78
43
79
-
#### REPL.prototype.createContext()
80
-
81
-
Returns a REPL context.
82
-
83
-
```javascript
84
-
// Create a new REPL:
85
-
var repl =newREPL();
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
+
<divclass="namespace-toc">
97
45
98
-
#### REPL.prototype.resetContext()
99
-
100
-
Resets a REPL's execution context.
101
-
102
-
```javascript
103
-
// Create a new REPL:
104
-
var repl =newREPL();
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 =newREPL();
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 =newREPL();
46
+
</div>
143
47
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 =newREPL();
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 =newREPL();
181
-
182
-
// ...
183
-
184
-
// Close the REPL:
185
-
repl.close();
186
-
```
187
-
188
-
* * *
48
+
<!-- </toc> -->
189
49
190
50
</section>
191
51
192
52
<!-- /.usage -->
193
53
194
-
<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
195
-
196
-
<sectionclass="notes">
197
-
198
-
</section>
199
-
200
-
<!-- /.notes -->
201
-
202
-
<!-- Package usage examples. -->
203
-
204
-
* * *
205
-
206
54
<sectionclass="examples">
207
55
208
56
## Examples
209
57
210
58
<!-- eslint no-undef: "error" -->
211
59
212
60
```javascript
213
-
varREPL=require( '@stdlib/repl/base' );
214
-
215
-
functiononCommand( cmd, success, res ) {
216
-
console.log( cmd +' = '+res.toString() );
217
-
}
218
-
219
-
// Create a new REPL:
220
-
var repl =newREPL();
221
-
repl.on( 'command', onCommand );
61
+
var objectKeys =require( '@stdlib/utils/keys' );
62
+
var ns =require( '@stdlib/repl/base' );
222
63
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 ) );
229
65
```
230
66
231
67
</section>
232
68
233
69
<!-- /.examples -->
234
70
235
-
* * *
236
-
237
-
<sectionclass="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
-
<sectionclass="references">
246
-
247
-
</section>
248
-
249
-
<!-- /.references -->
250
-
251
71
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
0 commit comments