---
title: ReadableStream
summary: This Streams API interface represents a readable stream of byte data. The Fetch API offers a concrete instance of a ReadableStream through the body property of a Response object.
url: https://www.fastly.com/documentation/reference/compute/sdks/javascript/js-compute/globals/interface.ReadableStream/
---

**Kind:** Interface  
**Module:** [globals](https://www.fastly.com/documentation/reference/compute/sdks/javascript/js-compute/globals/)  
**Package:** @fastly/js-compute 4.0.1  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L1854

```javascript
interface ReadableStream<R = any>
```

This Streams API interface represents a readable stream of byte data. The Fetch API offers a concrete instance of a ReadableStream through the body property of a Response object.

## Constructor

**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L1874

```javascript
new ReadableStream(underlyingSource?: UnderlyingSource<R>, strategy?: QueuingStrategy<R>)
```

The ReadableStream class as [specified by WHATWG](https://streams.spec.whatwg.org/#rs-class)

**See also**

- [ReadableStream on MDN](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream)

**Parameters**

- `underlyingSource`: `UnderlyingSource<R>` (optional)
- `strategy`: `QueuingStrategy<R>` (optional)

## Properties

### locked

**Type:** `boolean`  
**Flags:** read-only  
**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L1855

## Methods

### cancel

**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L1856

```javascript
cancel(reason?: any): Promise<void>
```

**Parameters**

- `reason`: `any` (optional)

**Returns**

`Promise<void>`

### getReader

**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L1857

```javascript
getReader(): ReadableStreamDefaultReader<R>
```

**Returns**

`ReadableStreamDefaultReader<R>`

### pipeThrough

**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L1858

```javascript
pipeThrough(transform: ReadableWritablePair<T, R>, options?: StreamPipeOptions): ReadableStream<T>
```

**Parameters**

- `transform`: `ReadableWritablePair<T, R>`
- `options`: `StreamPipeOptions` (optional)

**Returns**

`ReadableStream<T>`

### pipeTo

**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L1862

```javascript
pipeTo(dest: WritableStream<R>, options?: StreamPipeOptions): Promise<void>
```

**Parameters**

- `dest`: `WritableStream<R>`
- `options`: `StreamPipeOptions` (optional)

**Returns**

`Promise<void>`

### tee

**Source:** https://github.com/fastly/js-compute-runtime/blob/70cf30af4e657879b2d1e7eafab880e39e3a3f7d/types/globals.d.ts#L1863

```javascript
tee(): [ReadableStream<R>, ReadableStream<R>]
```

**Returns**

`[ReadableStream<R>, ReadableStream<R>]`
