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

Function copyFromBufferString

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

Source from the content-addressed store, hash-verified

25002// This function is designed to be inlinable, so please take care when making
25003// changes to the function body.
25004function copyFromBufferString(n, list) {
25005 var p = list.head;
25006 var c = 1;
25007 var ret = p.data;
25008 n -= ret.length;
25009 while (p = p.next) {
25010 var str = p.data;
25011 var nb = n > str.length ? str.length : n;
25012 if (nb === str.length) ret += str;else ret += str.slice(0, n);
25013 n -= nb;
25014 if (n === 0) {
25015 if (nb === str.length) {
25016 ++c;
25017 if (p.next) list.head = p.next;else list.head = list.tail = null;
25018 } else {
25019 list.head = p;
25020 p.data = str.slice(nb);
25021 }
25022 break;
25023 }
25024 ++c;
25025 }
25026 list.length -= c;
25027 return ret;
25028}
25029
25030// Copies a specified amount of bytes from the list of buffered data chunks.
25031// This function is designed to be inlinable, so please take care when making

Callers 1

fromListPartialFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected