(stream, state, isBuf, chunk, encoding, cb)
| 25241 | // in the queue, and wait our turn. Otherwise, call _write |
| 25242 | // If we return false, then we need a drain event, so set that flag. |
| 25243 | function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) { |
| 25244 | if (!isBuf) { |
| 25245 | var newChunk = decodeChunk(state, chunk, encoding); |
| 25246 | if (chunk !== newChunk) { |
| 25247 | isBuf = true; |
| 25248 | encoding = 'buffer'; |
| 25249 | chunk = newChunk; |
| 25250 | } |
| 25251 | } |
| 25252 | var len = state.objectMode ? 1 : chunk.length; |
| 25253 | |
| 25254 | state.length += len; |
| 25255 | |
| 25256 | var ret = state.length < state.highWaterMark; |
| 25257 | // we must ensure that previous needDrain will not be reset to false. |
| 25258 | if (!ret) state.needDrain = true; |
| 25259 | |
| 25260 | if (state.writing || state.corked) { |
| 25261 | var last = state.lastBufferedRequest; |
| 25262 | state.lastBufferedRequest = { |
| 25263 | chunk: chunk, |
| 25264 | encoding: encoding, |
| 25265 | isBuf: isBuf, |
| 25266 | callback: cb, |
| 25267 | next: null |
| 25268 | }; |
| 25269 | if (last) { |
| 25270 | last.next = state.lastBufferedRequest; |
| 25271 | } else { |
| 25272 | state.bufferedRequest = state.lastBufferedRequest; |
| 25273 | } |
| 25274 | state.bufferedRequestCount += 1; |
| 25275 | } else { |
| 25276 | doWrite(stream, state, false, len, chunk, encoding, cb); |
| 25277 | } |
| 25278 | |
| 25279 | return ret; |
| 25280 | } |
| 25281 | |
| 25282 | function doWrite(stream, state, writev, len, chunk, encoding, cb) { |
| 25283 | state.writelen = len; |
no test coverage detected