mute-stream
Advanced tools
Comparing version 0.0.3 to 0.0.4
19
mute.js
@@ -14,2 +14,8 @@ var Stream = require('stream') | ||
this.replace = opts.replace | ||
// For readline-type situations | ||
// This much at the start of a line being redrawn after a ctrl char | ||
// is seen (such as backspace) won't be redrawn as the replacement | ||
this._prompt = opts.prompt || null | ||
this._hadControl = false | ||
} | ||
@@ -98,3 +104,14 @@ | ||
if (!this.replace) return true | ||
c = c.toString().replace(/./g, this.replace) | ||
if (c.match(/^\u001b/)) { | ||
this._hadControl = true | ||
return this.emit('data', c) | ||
} else { | ||
if (this._prompt && this._hadControl && | ||
c.indexOf(this._prompt) === 0) { | ||
this._hadControl = false | ||
this.emit('data', this._prompt) | ||
c = c.substr(this._prompt.length) | ||
} | ||
c = c.toString().replace(/./g, this.replace) | ||
} | ||
} | ||
@@ -101,0 +118,0 @@ this.emit('data', c) |
{ | ||
"name": "mute-stream", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"main": "mute.js", | ||
@@ -5,0 +5,0 @@ "directories": { |
@@ -45,2 +45,8 @@ # mute-stream | ||
* `prompt` If you are using a replacement char, and also using a | ||
prompt with a readline stream (as for a `Password: *****` input), | ||
then specify what the prompt is so that backspace will work | ||
properly. Otherwise, pressing backspace will overwrite the prompt | ||
with the replacement character, which is weird. | ||
## ms.mute() | ||
@@ -47,0 +53,0 @@ |
@@ -22,2 +22,3 @@ var Stream = require('stream') | ||
this.emit('data', c) | ||
return true | ||
} | ||
@@ -24,0 +25,0 @@ }, |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
10838
304
69
0