MCPcopy Create free account
hub / github.com/TruthHun/BookStack / copyFromBuffer

Function copyFromBuffer

static/word2md/mammoth.browser.js:25033–25058  ·  view source on GitHub ↗
(n, list)

Source from the content-addressed store, hash-verified

25031// This function is designed to be inlinable, so please take care when making
25032// changes to the function body.
25033function 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
25060function endReadable(stream) {
25061 var state = stream._readableState;

Callers 1

fromListPartialFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected