lib/streams.js
function transformPair(input, fn) {
  let incomingTransformController;
  const incoming = new TransformStream({
    start(controller) {
      incomingTransformController = controller;
    }
  });

  const pipeDonePromise = pipe(input, incoming.writable);

  const outgoing = transformWithCancel(async function() {
    incomingTransformController.error(new Error('Readable side was canceled.'));
    await pipeDonePromise;
    await new Promise(setTimeout);
  });
  fn(incoming.readable, outgoing.writable);
  return outgoing.readable;
}
function transformPair(input, fn) {
  let incomingTransformController;
  const incoming = new TransformStream({
    start(controller) {
      incomingTransformController = controller;
    }
  });

  const pipeDonePromise = pipe(input, incoming.writable);

  const outgoing = transformWithCancel(async function() {
    incomingTransformController.error(new Error('Readable side was canceled.'));
    await pipeDonePromise;
    await new Promise(setTimeout);
  });
  fn(incoming.readable, outgoing.writable);
  return outgoing.readable;
}
function transformPair ( input , fn ) { let incomingTransformController ; const incoming = new TransformStream ( { start ( controller ) { incomingTransformController = controller ; } } ) ; const pipeDonePromise = pipe ( input , incoming . writable ) ; const outgoing = transformWithCancel ( async function ( ) { incomingTransformController . error ( new Error ( 'Readable side was canceled.' ) ) ; await pipeDonePromise ; await new Promise ( setTimeout ) ; } ) ; fn ( incoming . readable , outgoing . writable ) ; return outgoing . readable ; }
Transform a stream using a helper function which is passed a readable and a writable stream.
This function also maintains the possibility to cancel the input stream,
and does so on cancelation of the output stream, despite cancelation
normally being impossible when the input stream is being read from.
@param {ReadableStream|Uint8array|String} input
@param {Function} fn
@returns {ReadableStream}
Transform a stream using a helper function which is passed a readable and a writable stream . This function also maintains the possibility to cancel the input stream and does so on cancelation of the output stream despite cancelation normally being impossible when the input stream is being read from .