summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2013-03-03 19:43:46 -0800
committerisaacs <i@izs.me>2013-03-05 14:27:16 -0800
commit312289b791a5924eec5748fbd19ad6867ff37320 (patch)
treef9452abcd649113b3e3289b749b2dd6fd992c31b
parent426b4c625802c7b6913fa09237aa9745bf3ae84a (diff)
downloadnode-new-312289b791a5924eec5748fbd19ad6867ff37320.tar.gz
stream: Use class for write buffer entries
-rw-r--r--lib/_stream_writable.js14
-rw-r--r--test/simple/test-stream2-transform.js2
2 files changed, 11 insertions, 5 deletions
diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js
index 57926ad57b..bcbe88c11b 100644
--- a/lib/_stream_writable.js
+++ b/lib/_stream_writable.js
@@ -32,6 +32,12 @@ var Stream = require('stream');
util.inherits(Writable, Stream);
+function WriteReq(chunk, encoding, cb) {
+ this.chunk = chunk;
+ this.encoding = encoding;
+ this.callback = cb;
+}
+
function WritableState(options, stream) {
options = options || {};
@@ -190,7 +196,7 @@ function writeOrBuffer(stream, state, chunk, encoding, cb) {
state.needDrain = !ret;
if (state.writing)
- state.buffer.push([chunk, encoding, cb]);
+ state.buffer.push(new WriteReq(chunk, encoding, cb));
else
doWrite(stream, state, len, chunk, encoding, cb);
@@ -268,9 +274,9 @@ function clearBuffer(stream, state) {
for (var c = 0; c < state.buffer.length; c++) {
var entry = state.buffer[c];
- var chunk = entry[0];
- var encoding = entry[1];
- var cb = entry[2];
+ var chunk = entry.chunk;
+ var encoding = entry.encoding;
+ var cb = entry.callback;
var len = state.objectMode ? 1 : chunk.length;
doWrite(stream, state, len, chunk, encoding, cb);
diff --git a/test/simple/test-stream2-transform.js b/test/simple/test-stream2-transform.js
index a329dee1d9..3f629a23a4 100644
--- a/test/simple/test-stream2-transform.js
+++ b/test/simple/test-stream2-transform.js
@@ -82,7 +82,7 @@ test('writable side consumption', function(t) {
t.equal(transformed, 10);
t.equal(tx._transformState.writechunk.length, 5);
t.same(tx._writableState.buffer.map(function(c) {
- return c[0].length;
+ return c.chunk.length;
}), [6, 7, 8, 9, 10]);
t.end();