# Fx.collectUpTo

Collects the first `n` values emitted by an `Fx` into an array.

## Signatures

```ts
export declare const collectUpTo: {
    (upTo: number): <A, E, R>(fx: Fx<A, E, R>) => Effect.Effect<ReadonlyArray<A>, E, R>;
    <A, E, R>(fx: Fx<A, E, R>, upTo: number): Effect.Effect<ReadonlyArray<A>, E, R>;
};
```

## Why

`collectUpTo` creates a bounded pull result from a push source and stops upstream as
soon as the requested cardinality has arrived.

## Ownership and lifetime

Each Effect run owns a fresh array and source subscription. At most `upTo` values
are retained in producer order; reaching the bound requests early exit and cleans
up upstream. If the source completes first, the shorter array is returned. Source
failures before completion remain typed.

## Examples

```ts
import { collectUpTo, fromIterable } from "@typed/fx/Fx"

const firstTwo = collectUpTo(fromIterable([1, 2, 3]), 2)
```
