| 25031 | // This function is designed to be inlinable, so please take care when making |
| 25032 | // changes to the function body. |
| 25033 | function copyFromBuffer(n, list) { |
| 25034 | var ret = bufferShim.allocUnsafe(n); |
| 25035 | var p = list.head; |
| 25036 | var c = 1; |
| 25037 | p.data.copy(ret); |
| 25038 | n -= p.data.length; |
| 25039 | while (p = p.next) { |
| 25040 | var buf = p.data; |
| 25041 | var nb = n > buf.length ? buf.length : n; |
| 25042 | buf.copy(ret, ret.length - n, 0, nb); |
| 25043 | n -= nb; |
| 25044 | if (n === 0) { |
| 25045 | if (nb === buf.length) { |
| 25046 | ++c; |
| 25047 | if (p.next) list.head = p.next;else list.head = list.tail = null; |
| 25048 | } else { |
| 25049 | list.head = p; |
| 25050 | p.data = buf.slice(nb); |
| 25051 | } |
| 25052 | break; |
| 25053 | } |
| 25054 | ++c; |
| 25055 | } |
| 25056 | list.length -= c; |
| 25057 | return ret; |
| 25058 | } |
| 25059 | |
| 25060 | function endReadable(stream) { |
| 25061 | var state = stream._readableState; |