MCPcopy Create free account
hub / github.com/bewcloud/bewcloud / fromListPartial

Function fromListPartial

lib/models/dav.js:5704–5718  ·  view source on GitHub ↗
(n, list, hasStrings)

Source from the content-addressed store, hash-verified

5702// This function is designed to be inlinable, so please take care when making
5703// changes to the function body.
5704function fromListPartial(n, list, hasStrings) {
5705 var ret;
5706 if (n < list.head.data.length) {
5707 // slice is the same for buffers and strings
5708 ret = list.head.data.slice(0, n);
5709 list.head.data = list.head.data.slice(n);
5710 } else if (n === list.head.data.length) {
5711 // first chunk is a perfect match
5712 ret = list.shift();
5713 } else {
5714 // result spans more than one buffer
5715 ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
5716 }
5717 return ret;
5718}
5719
5720// Copies a specified amount of characters from the list of buffered data
5721// chunks.

Callers 1

fromListFunction · 0.85

Calls 2

copyFromBufferStringFunction · 0.85
copyFromBufferFunction · 0.85

Tested by

no test coverage detected