2525var repeat = require ( '@stdlib/string/repeat' ) ;
2626
2727
28+ // FUNCTIONS //
29+
30+ /**
31+ * Callback invoked upon a `drain` event.
32+ *
33+ * @private
34+ * @param {Presentation } pres - presentation instance
35+ */
36+ function onDrain ( pres ) {
37+ /*
38+ * [ANSI escape sequences][1]:
39+ *
40+ * - `\u001b`: ESC, the escape character
41+ * - `[1T`: scroll down one line
42+ * - `[1G`: move the cursor to the beginning of the line
43+ *
44+ * [1]: https://en.wikipedia.org/wiki/ANSI_escape_code
45+ */
46+ var str = '\u001b[1T\u001b[1G' ;
47+ pres . _repl . _ostream . write ( str ) ;
48+ }
49+
50+
2851// MAIN //
2952
3053/**
@@ -45,25 +68,16 @@ function command( pres ) {
4568 function onCommand ( ) {
4669 var str = repeat ( pres . _opts . newline , pres . height + 1 ) ;
4770 pres . _repl . _ostream . write ( str ) ;
48- pres . _repl . once ( 'drain' , onDrain ) ;
71+
72+ pres . _repl . once ( 'drain' , drain ) ;
4973
5074 /**
5175 * Callback invoked upon a `drain` event.
5276 *
5377 * @private
5478 */
55- function onDrain ( ) {
56- /*
57- * [ANSI escape sequences][1]:
58- *
59- * - `\u001b`: ESC, the escape character
60- * - `[1T`: scroll down one line
61- * - `[1G`: move the cursor to the beginning of the line
62- *
63- * [1]: https://en.wikipedia.org/wiki/ANSI_escape_code
64- */
65- var str = '\u001b[1T\u001b[1G' ;
66- pres . _repl . _ostream . write ( str ) ;
79+ function drain ( ) {
80+ onDrain ( pres ) ;
6781 }
6882 }
6983}
0 commit comments