MCPcopy Index your code
hub / github.com/nodejs/node / processChunkSync

Function processChunkSync

lib/zlib.js:400–482  ·  view source on GitHub ↗
(self, chunk, flushFlag)

Source from the content-addressed store, hash-verified

398};
399
400function processChunkSync(self, chunk, flushFlag) {
401 let availInBefore = chunk.byteLength;
402 let availOutBefore = self._chunkSize - self._outOffset;
403 let inOff = 0;
404 let availOutAfter;
405 let availInAfter;
406
407 const buffers = [];
408 let nread = 0;
409 let inputRead = 0;
410 const state = self._writeState;
411 const handle = self._handle;
412 let buffer = self._outBuffer;
413 let offset = self._outOffset;
414 const chunkSize = self._chunkSize;
415
416 let error;
417 self.on('error', function onError(er) {
418 error = er;
419 });
420
421 while (true) {
422 handle.writeSync(flushFlag,
423 chunk, // in
424 inOff, // in_off
425 availInBefore, // in_len
426 buffer, // out
427 offset, // out_off
428 availOutBefore); // out_len
429 if (error)
430 throw error;
431 else if (self[kError])
432 throw self[kError];
433
434 availOutAfter = state[0];
435 availInAfter = state[1];
436
437 const inDelta = (availInBefore - availInAfter);
438 inputRead += inDelta;
439
440 const have = availOutBefore - availOutAfter;
441 if (have > 0) {
442 const out = buffer.slice(offset, offset + have);
443 offset += have;
444 buffers.push(out);
445 nread += out.byteLength;
446
447 if (nread > self._maxOutputLength) {
448 _close(self);
449 throw new ERR_BUFFER_TOO_LARGE(self._maxOutputLength);
450 }
451
452 } else {
453 assert(have === 0, 'have should not go down');
454 }
455
456 // Exhausted the output buffer, or used all the input create a new one.
457 if (availOutAfter === 0 || offset >= chunkSize) {

Callers 2

zlibBufferSyncFunction · 0.85
zlib.jsFile · 0.85

Calls 7

concatMethod · 0.80
_closeFunction · 0.70
assertFunction · 0.70
sliceMethod · 0.65
onMethod · 0.45
writeSyncMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…