stream: Allow strings in Readable.push/unshift

Fix #4909
This commit is contained in:
isaacs committed 2013-03-06 11:44:30 -08:00
1 parent b0f6789a78
commit a978bedee7
2 files changed
+70

No files matched your search

+4
View File
@@ -98,11 +98,15 @@ function Readable(options) {
// write() some more.
Readable.prototype.push = function(chunk) {
var state = this._readableState;
if (typeof chunk === 'string' && !state.objectMode)
chunk = new Buffer(chunk, arguments[1]);
return readableAddChunk(this, state, chunk, false);
};
Readable.prototype.unshift = function(chunk) {
var state = this._readableState;
if (typeof chunk === 'string' && !state.objectMode)
chunk = new Buffer(chunk, arguments[1]);
return readableAddChunk(this, state, chunk, true);
};