# stream

```ts
function stream<T, R>(iterable: AsyncIterable<T, R>): Stream<T, R>
```

Convert any [`AsyncIterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols) into an Effection [Stream](https://frontside.com/effection/api/v4/Stream.md).

This allows you to consume any `AsyncIterable` as a [Stream](https://frontside.com/effection/api/v4/Stream.md).

### Examples
#### Example 1
```ts
import { each, stream, until } from "effection";

let response = yield* until(fetch("https://example.com/data.bin"));
if (!response.body) throw new Error("response has no body");

for (let chunk of yield* each(stream(response.body))) {
  console.log(chunk.byteLength);
  yield* each.next();
}
```

---
### Type Parameters
T


R


### Parameters


**iterable**: AsyncIterable&lt;T, R&gt;


the async iterable to convert
### Return Type


[Stream](https://frontside.com/effection/api/v4/Stream.md)&lt;T, R&gt;


a stream that will produce each item of `iterable`

[View code](https://github.com/thefrontside/effection/tree/effection-v4.2.0/lib/async.ts#L58)
