public function pipe(Context $context, WritableStream $stream, bool $close = false): Promise
    {
        return $context->task(function (Context $context) use ($stream, $close) {
            $len = 0;
            
            try {
                while (null != ($chunk = yield $this->read($context, 0xFFFF))) {
                    $len += yield $stream->write($context, $chunk);
                }
            } finally {
                $this->close();
                
                if ($close) {
                    $stream->close();
                }
            }
            
            return $len;
        });
    }
public function pipe(Context $context, WritableStream $stream, bool $close = false): Promise
    {
        return $context->task(function (Context $context) use ($stream, $close) {
            $len = 0;
            
            try {
                while (null != ($chunk = yield $this->read($context, 0xFFFF))) {
                    $len += yield $stream->write($context, $chunk);
                }
            } finally {
                $this->close();
                
                if ($close) {
                    $stream->close();
                }
            }
            
            return $len;
        });
    }
public function pipe ( Context $ context , WritableStream $ stream , bool $ close = false ) : Promise { return $ context -> task ( function ( Context $ context ) use ( $ stream , $ close ) { $ len = 0 ; try { while ( null != ( $ chunk = yield $ this -> read ( $ context , 0xFFFF ) ) ) { $ len += yield $ stream -> write ( $ context , $ chunk ) ; } } finally { $ this -> close ( ) ; if ( $ close ) { $ stream -> close ( ) ; } } return $ len ; } ) ; }
Copy remaining stream contents to the given stream.

The readable stream will be closed after all bytes have been copied.

@param Context $context Async execution context.
@param WritableStream $stream Target stream to receive the data.
@param bool $close Close writable stream after contents have been copied?
@return int Number of bytes that have been copied.

@throws StreamClosedException When the stream has been closed.
Copy remaining stream contents to the given stream .