packages/mesh/lib/streams/std/readable-stream.js
function ReadableByteStreamControllerClose(controller) {
  const stream = controller._controlledReadableStream;

  assert(controller._closeRequested === false);
  assert(stream._state === 'readable');

  if (controller._totalQueuedBytes > 0) {
    controller._closeRequested = true;

    return;
  }

  if (controller._pendingPullIntos.length > 0) {
    const firstPendingPullInto = controller._pendingPullIntos[0];
    if (firstPendingPullInto.bytesFilled > 0) {
      const e = new TypeError('Insufficient bytes to fill elements in the given buffer');
      ReadableByteStreamControllerError(controller, e);

      throw e;
    }
  }

  ReadableStreamClose(stream);
}
function ReadableByteStreamControllerClose(controller) {
  const stream = controller._controlledReadableStream;

  assert(controller._closeRequested === false);
  assert(stream._state === 'readable');

  if (controller._totalQueuedBytes > 0) {
    controller._closeRequested = true;

    return;
  }

  if (controller._pendingPullIntos.length > 0) {
    const firstPendingPullInto = controller._pendingPullIntos[0];
    if (firstPendingPullInto.bytesFilled > 0) {
      const e = new TypeError('Insufficient bytes to fill elements in the given buffer');
      ReadableByteStreamControllerError(controller, e);

      throw e;
    }
  }

  ReadableStreamClose(stream);
}
function ReadableByteStreamControllerClose ( controller ) { const stream = controller . _controlledReadableStream ; assert ( controller . _closeRequested === false ) ; assert ( stream . _state === 'readable' ) ; if ( controller . _totalQueuedBytes > 0 ) { controller . _closeRequested = true ; return ; } if ( controller . _pendingPullIntos . length > 0 ) { const firstPendingPullInto = controller . _pendingPullIntos [ 0 ] ; if ( firstPendingPullInto . bytesFilled > 0 ) { const e = new TypeError ( 'Insufficient bytes to fill elements in the given buffer' ) ; ReadableByteStreamControllerError ( controller , e ) ; throw e ; } } ReadableStreamClose ( stream ) ; }
A client of ReadableByteStreamController may use these functions directly to bypass state check.
A client of ReadableByteStreamController may use these functions directly to bypass state check .