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

Function writev

lib/internal/streams/iter/classic.js:620–663  ·  view source on GitHub ↗
(chunks)

Source from the content-addressed store, hash-verified

618 },
619
620 writev(chunks) {
621 if (!ArrayIsArray(chunks)) {
622 throw new ERR_INVALID_ARG_TYPE('chunks', 'Array', chunks);
623 }
624 if (!isWritable()) {
625 return PromiseReject(new ERR_STREAM_WRITE_AFTER_END());
626 }
627
628 if (backpressure === 'strict' && isFull()) {
629 return PromiseReject(new ERR_INVALID_STATE.RangeError(
630 'Backpressure violation: buffer is full. ' +
631 'Await each write() call to respect backpressure.'));
632 }
633
634 if (backpressure === 'drop-newest' && isFull()) {
635 // Discard entire batch.
636 for (let i = 0; i < chunks.length; i++) {
637 totalBytes +=
638 TypedArrayPrototypeGetByteLength(toUint8Array(chunks[i]));
639 }
640 return PromiseResolve();
641 }
642
643 let ok = true;
644 if (typeof writable.cork === 'function' &&
645 typeof writable.uncork === 'function') {
646 writable.cork();
647 try {
648 ok = writeChunks(chunks);
649 } finally {
650 writable.uncork();
651 }
652 } else {
653 ok = writeChunks(chunks);
654 }
655
656 if (ok) return PromiseResolve();
657
658 if (backpressure === 'block') {
659 return waitForDrain();
660 }
661
662 return PromiseResolve();
663 },
664
665 endSync() {
666 return -1;

Callers

nothing calls this directly

Calls 7

isFullFunction · 0.85
toUint8ArrayFunction · 0.85
corkMethod · 0.80
uncorkMethod · 0.80
isWritableFunction · 0.70
writeChunksFunction · 0.70
waitForDrainFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…