@@ -114,17 +114,17 @@ The next table demonstrates available API. Left column are `terminal` object pro
114114 <tr>
115115 <td>onOutput([ <b>options</b> ], <b>callback</b>)</td>
116116 <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
118118 prompted for input, and <code>strings</code> array will always contain an array of
119119 chunks of all the text printed between the prompts. For example, if user writes
120120 <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
122122 <code>write 1, 2, 3</code>, <code>strings</code> will result with
123123 <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/>
125125 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.
128128 </td>
129129 </tr>
130130 <tr>
@@ -177,7 +177,7 @@ function myInitHandler (terminal) {
177177 terminal .onOutput ((chunks ) => {
178178 // If you "write 12", chunks are ["\r\n", "12", "\r\n"].
179179 // 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"
181181 alert (` You've found a secret phrase!` );
182182 }
183183 });
0 commit comments