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

Method writeSync

lib/internal/streams/iter/push.js:151–182  ·  view source on GitHub ↗

* Write chunks synchronously if possible. * Returns true if write completed, false if buffer is full. * @returns {boolean}

(chunks)

Source from the content-addressed store, hash-verified

149 * @returns {boolean}
150 */
151 writeSync(chunks) {
152 if (this.#writerState !== 'open') return false;
153 if (this.#consumerState !== 'active') return false;
154
155 if (this.#slots.length >= this.#highWaterMark) {
156 switch (this.#backpressure) {
157 case 'strict':
158 return false;
159 case 'block':
160 return false;
161 case 'drop-oldest':
162 if (this.#slots.length > 0) {
163 this.#slots.shift();
164 }
165 break;
166 case 'drop-newest':
167 // Discard this write, but return true
168 for (let i = 0; i < chunks.length; i++) {
169 this.#bytesWritten += TypedArrayPrototypeGetByteLength(chunks[i]);
170 }
171 return true;
172 }
173 }
174
175 this.#slots.push(chunks);
176 for (let i = 0; i < chunks.length; i++) {
177 this.#bytesWritten += TypedArrayPrototypeGetByteLength(chunks[i]);
178 }
179
180 this.#resolvePendingReads();
181 return true;
182 }
183
184 /**
185 * Write chunks asynchronously.

Callers 15

writeAsyncMethod · 0.95
constructorMethod · 0.45
#actualWriteBufferMethod · 0.45
#actualWriteUtf8Method · 0.45
#flushBufferSyncMethod · 0.45
#flushSyncUtf8Method · 0.45
_writeFunction · 0.45
processSyncInputFunction · 0.45
pipeToSyncFunction · 0.45
writeBatchAsyncFallbackFunction · 0.45
writeBatchFunction · 0.45
writeMethod · 0.45

Calls 3

#resolvePendingReadsMethod · 0.95
shiftMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected