MCPcopy
hub / github.com/webpack/webpack / readSlice

Function readSlice

lib/serialization/FileMiddleware.js:327–342  ·  view source on GitHub ↗
(l)

Source from the content-addressed store, hash-verified

325 * @returns {Buffer} buffer
326 */
327 const readSlice = (l) => {
328 ensureData(l);
329 if (contentPosition === 0 && contentItemLength === l) {
330 const result = contentItem;
331 if (contentsIndex + 1 < contents.length) {
332 nextContent();
333 } else {
334 contentPosition = l;
335 }
336 return result;
337 }
338 const result = contentItem.subarray(contentPosition, contentPosition + l);
339 contentPosition += l;
340 // we clone the buffer here to allow the original content to be garbage collected
341 return l * 2 < contentItem.buffer.byteLength ? Buffer.from(result) : result;
342 };
343 const version = readUInt32LE();
344 if (version !== VERSION) {
345 throw new Error("Invalid file version");

Callers 1

deserializeFunction · 0.85

Calls 2

ensureDataFunction · 0.85
nextContentFunction · 0.85

Tested by

no test coverage detected