* @param {ArrayBufferView} chunk
(chunk)
| 1252 | * @param {ArrayBufferView} chunk |
| 1253 | */ |
| 1254 | enqueue(chunk) { |
| 1255 | if (!isReadableByteStreamController(this)) |
| 1256 | throw new ERR_INVALID_THIS('ReadableByteStreamController'); |
| 1257 | validateBuffer(chunk); |
| 1258 | const chunkByteLength = ArrayBufferViewGetByteLength(chunk); |
| 1259 | const chunkBuffer = ArrayBufferViewGetBuffer(chunk); |
| 1260 | |
| 1261 | if (isSharedArrayBuffer(chunkBuffer)) { |
| 1262 | throw new ERR_INVALID_ARG_VALUE( |
| 1263 | 'chunk', |
| 1264 | chunk, |
| 1265 | 'must not be backed by a SharedArrayBuffer', |
| 1266 | ); |
| 1267 | } |
| 1268 | |
| 1269 | const chunkBufferByteLength = ArrayBufferPrototypeGetByteLength(chunkBuffer); |
| 1270 | if (chunkByteLength === 0 || chunkBufferByteLength === 0) { |
| 1271 | throw new ERR_INVALID_STATE.TypeError( |
| 1272 | 'chunk ArrayBuffer is zero-length or detached'); |
| 1273 | } |
| 1274 | if (this[kState].closeRequested) |
| 1275 | throw new ERR_INVALID_STATE.TypeError('Controller is already closed'); |
| 1276 | if (this[kState].stream[kState].state !== 'readable') |
| 1277 | throw new ERR_INVALID_STATE.TypeError('ReadableStream is already closed'); |
| 1278 | readableByteStreamControllerEnqueue(this, chunk); |
| 1279 | } |
| 1280 | |
| 1281 | /** |
| 1282 | * @param {any} [error] |
no test coverage detected