readline-ui
Advanced tools
Comparing version 2.2.1 to 2.2.2
41
index.js
@@ -49,3 +49,3 @@ 'use strict'; | ||
this.rl.input.on('keypress', self.onKeypress); | ||
this.rl.resume(); | ||
this.resume(); | ||
@@ -177,2 +177,11 @@ this.rl.on('line', function(line) { | ||
/** | ||
* Resume the input stream. | ||
* @api public | ||
*/ | ||
UI.prototype.resume = function() { | ||
this.rl.resume(); | ||
}; | ||
/** | ||
* Pause the input stream, allowing it to be resumed later if necessary. | ||
@@ -238,2 +247,30 @@ * @api public | ||
/** | ||
* Mutes the output stream that was used to create the | ||
* readline interface, and returns a function for unmuting the | ||
* stream. This is useful in unit tests. | ||
* | ||
* ```js | ||
* // mute the stream | ||
* var unmute = ui.mute(); | ||
* | ||
* // unmute the stream | ||
* unmute(); | ||
* ``` | ||
* @return {Function} | ||
* @api public | ||
*/ | ||
UI.prototype.mute = function() { | ||
var rl = this.rl; | ||
var unmute = rl.output.unmute; | ||
rl.output.unmute = function() {}; | ||
rl.output.mute(); | ||
return function() { | ||
rl.output.unmute = unmute; | ||
unmute(); | ||
}; | ||
}; | ||
/** | ||
* Unmute then write to the output stream that was used | ||
@@ -248,3 +285,3 @@ * to create the readline interface, then re-mute the stream. | ||
this.rl.output.unmute(); | ||
this.rl.output.write(util.inspect.apply(util, input)); | ||
this.rl.output.write(util.inspect.apply(util, arguments)); | ||
this.rl.output.mute(); | ||
@@ -251,0 +288,0 @@ }; |
{ | ||
"name": "readline-ui", | ||
"description": "Create readline interface to use in prompts.", | ||
"version": "2.2.1", | ||
"version": "2.2.2", | ||
"homepage": "https://github.com/enquirer/readline-ui", | ||
@@ -6,0 +6,0 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)", |
15128
248