ByIdDirectPrivate(source, "underlyingByteSource") !== @undefined)
        return @Promise.@reject("Piping of readable by strean is not supported");

    let pipeState = { source : source, destination : destination, preventAbort : preventAbort, preventCancel : preventCancel, preventClose : preventClose, signal : signal };

    pipeState.reader = @acquireReadableStreamDefaultReader(source);
    pipeState.writer = @acquireWritableStreamDefaultWriter(destination);

    @putByIdDirectPrivate(source, "disturbed", true);

    pipeState.shuttingDown = false;
    pipeState.promiseCapability = @newPromiseCapability(@Promise);
    pipeState.pendingReadPromiseCapability = @newPromiseCapability(@Promise);
    pipeState.pendingReadPromiseCapability.resolve.@call();
    pipeState.pendingWritePromise = @Promise.@resolve();

    if (signal !== @undefined) {
        const algorithm = (reason) => {
            @pipeToShutdownWithAction(pipeState, () => {
                const shouldAbortDestination = !pipeState.preventAbort && @getByIdDirectPrivate(pipeState.destination, "state") === "writable";
                const promiseDestination = shouldAbortDestination ? @writableStreamAbort(pipeState.destination, reason) : @Promise.@resolve();

                const shouldAbortSource = !pipeState.preventCancel && @getByIdDirectPrivate(pipeState.source, "state") === @streamReadable;
                const promiseSource = shouldAbortSource ? @readableStreamCancel(pipeState.source, reason) : @Promise.@resolve();

                let promiseCapability = @newPromiseCapability(@Promise);
                let shouldWait = true;
                let handleResolvedPromise = () => {
                    if (shouldWait) {
                        shouldWait = false;
                        return;
                    }
                    promiseCapability.resolve.@call();
                }
                let handleRejectedPromise = (e) => {
                    promiseCapability.reject.@call(@undefined, e);
                }
                promiseDestination.@then(handleResolvedPromise, handleRejectedPromise);
                promiseSource.@then(handleResolvedPromise, handleRejectedPromise);
                return promiseCapability.promise;
            }, reason);
        };
        pipeState.abortAlgorithmIdentifier = @addAbortAlgorithmToSignal(signal, algorithm)
        if (!pipeState.abortAlgorithmIdentifier)
            return pipeState.promiseCapability.promise;
        pipeState.signal = signal;
    }

    @pipeToErrorsMustBePropagatedForward(pipeState);
    @pipeToErrorsMustBePropagatedBackward(pipeState);
    @pipeToClosingMustBePropagatedForward(pipeState);
    @pipeToClosingMustBePropagatedBackward(pipeState);

    @pipeToLoop(pipeState);

    return pipeState.promiseCapability.promise;
})
