(chunk, options = kEmptyObject)
| 2170 | } |
| 2171 | |
| 2172 | async function write(chunk, options = kEmptyObject) { |
| 2173 | validateObject(options, 'options'); |
| 2174 | const { signal } = options; |
| 2175 | if (signal !== undefined) { |
| 2176 | validateAbortSignal(signal, 'options.signal'); |
| 2177 | signal.throwIfAborted(); |
| 2178 | } |
| 2179 | if (errored) throw error; |
| 2180 | if (closed || stream.#inner.state.writeEnded) { |
| 2181 | throw new ERR_INVALID_STATE('Writer is closed'); |
| 2182 | } |
| 2183 | // If a drain is already pending, another operation is waiting |
| 2184 | // for capacity. Under strict policy, reject immediately. |
| 2185 | // Later, if we add support for other backpressure policies, |
| 2186 | // we could instead await the existing drain before proceeding. |
| 2187 | if (drainWakeup != null) { |
| 2188 | throw new ERR_INVALID_STATE('Stream write buffer is full'); |
| 2189 | } |
| 2190 | |
| 2191 | if (!writeSync(chunk)) { |
| 2192 | throw new ERR_INVALID_STATE('Stream write buffer is full'); |
| 2193 | } |
| 2194 | } |
| 2195 | |
| 2196 | function writevSync(chunks) { |
| 2197 | if (closed || errored || stream.#inner.state.writeEnded || drainWakeup != null) { |
no test coverage detected