| 7030 | // This function is designed to be inlinable, so please take care when making |
| 7031 | // changes to the function body. |
| 7032 | function copyFromBuffer(n, list) { |
| 7033 | var ret = Buffer.allocUnsafe(n); |
| 7034 | var p = list.head; |
| 7035 | var c = 1; |
| 7036 | p.data.copy(ret); |
| 7037 | n -= p.data.length; |
| 7038 | while (p = p.next) { |
| 7039 | var buf = p.data; |
| 7040 | var nb = n > buf.length ? buf.length : n; |
| 7041 | buf.copy(ret, ret.length - n, 0, nb); |
| 7042 | n -= nb; |
| 7043 | if (n === 0) { |
| 7044 | if (nb === buf.length) { |
| 7045 | ++c; |
| 7046 | if (p.next) list.head = p.next;else list.head = list.tail = null; |
| 7047 | } else { |
| 7048 | list.head = p; |
| 7049 | p.data = buf.slice(nb); |
| 7050 | } |
| 7051 | break; |
| 7052 | } |
| 7053 | ++c; |
| 7054 | } |
| 7055 | list.length -= c; |
| 7056 | return ret; |
| 7057 | } |
| 7058 | |
| 7059 | function endReadable(stream) { |
| 7060 | var state = stream._readableState; |