@@ -114,17 +114,17 @@ The next table demonstrates available API. Left column are `terminal` object pro
114
114
<tr>
115
115
<td>onOutput([ <b>options</b> ], <b>callback</b>)</td>
116
116
<td>
117
- By default, <code >callback</code >(<u>strings</u>) will be called before the user is
117
+ By default, <b >callback</b >(<u>strings</u>) will be called before the user is
118
118
prompted for input, and <code>strings</code> array will always contain an array of
119
119
chunks of all the text printed between the prompts. For example, if user writes
120
120
<code>write 123</code> and presses "Enter", the <code>strings</code> will contain
121
- this array: <code>["\r\n", "1 ", "\r\n"]</code>. However, when user enters
121
+ this array: <code>["\r\n", "123 ", "\r\n"]</code>. However, when user enters
122
122
<code>write 1, 2, 3</code>, <code>strings</code> will result with
123
123
<code>["\r\n", "1", "2", "3", "\r\n"]</code>. You can join this array with
124
- <code>join</code> array method to get the full output.<br/>
124
+ <code>join("") </code> array method to get the full output.<br/>
125
125
Optional <code>options</code> object may include <code>stream</code> property, which
126
- is <code>false</code> by default. When set to <code>true</code>, callback will be
127
- fired any time any chunk is print to the terminal simultaneously.
126
+ is <code>false</code> by default. When set to <code>true</code>, <b> callback</b>
127
+ will be fired every time something is printed to the terminal simultaneously.
128
128
</td>
129
129
</tr>
130
130
<tr>
@@ -177,7 +177,7 @@ function myInitHandler (terminal) {
177
177
terminal .onOutput ((chunks ) => {
178
178
// If you "write 12", chunks are ["\r\n", "12", "\r\n"].
179
179
// If you "write 1, 2", chunks are ["\r\n", "1", "2", "\r\n"].
180
- if (chunks[ 1 ] === " duck" ) {
180
+ if (chunks . slice ( 1 , - 1 ). join ( " " ) === " duck" ) { // if user do enters: write "duck"
181
181
alert (` You've found a secret phrase!` );
182
182
}
183
183
});
0 commit comments