MCPcopy
hub / github.com/webpack/webpack / readUpTo

Method readUpTo

lib/serialization/BinaryMiddleware.js:260–272  ·  view source on GitHub ↗

* Reads up to n bytes. * @param {number} n amount of bytes to read * @returns {Buffer} buffer with bytes

(n)

Source from the content-addressed store, hash-verified

258 * @returns {Buffer} buffer with bytes
259 */
260 readUpTo(n) {
261 this.ensureBuffer();
262 const rem =
263 /** @type {Buffer} */ (this.currentBuffer).length - this.currentPosition;
264 if (rem < n) {
265 n = rem;
266 }
267 const b = /** @type {Buffer} */ (this.currentBuffer);
268 const res = Buffer.from(b.buffer, b.byteOffset + this.currentPosition, n);
269 this.currentPosition += n;
270 this.checkOverflow();
271 return res;
272 }
273
274 /**
275 * Returns u8.

Callers 1

Calls 2

ensureBufferMethod · 0.95
checkOverflowMethod · 0.95

Tested by

no test coverage detected